id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
16,500
stubbles/stubbles-webapp-core
src/main/php/routing/Routing.php
Routing.postInterceptOnDelete
public function postInterceptOnDelete($postInterceptor, string $path = null): RoutingConfigurator { return $this->postIntercept($postInterceptor, $path, 'DELETE'); }
php
public function postInterceptOnDelete($postInterceptor, string $path = null): RoutingConfigurator { return $this->postIntercept($postInterceptor, $path, 'DELETE'); }
[ "public", "function", "postInterceptOnDelete", "(", "$", "postInterceptor", ",", "string", "$", "path", "=", "null", ")", ":", "RoutingConfigurator", "{", "return", "$", "this", "->", "postIntercept", "(", "$", "postInterceptor", ",", "$", "path", ",", "'DELETE'", ")", ";", "}" ]
post intercept with given class or callable on all DELETE requests @param string|callable|\stubbles\webapp\interceptor\PostInterceptor $postInterceptor post interceptor to add @param string $path optional path for which post interceptor should be executed @return \stubbles\webapp\RoutingConfigurator
[ "post", "intercept", "with", "given", "class", "or", "callable", "on", "all", "DELETE", "requests" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L458-L461
16,501
stubbles/stubbles-webapp-core
src/main/php/routing/Routing.php
Routing.postIntercept
public function postIntercept($postInterceptor, string $path = null, string $requestMethod = null): RoutingConfigurator { if (!is_callable($postInterceptor) && !($postInterceptor instanceof PostInterceptor) && !class_exists((string) $postInterceptor)) { throw new \InvalidArgumentException( 'Given pre interceptor must be a callable, an instance of ' . PostInterceptor::class . ' or a class name of an existing post interceptor class' ); } $this->postInterceptors[] = [ 'interceptor' => $postInterceptor, 'requestMethod' => $requestMethod, 'path' => $path ]; return $this; }
php
public function postIntercept($postInterceptor, string $path = null, string $requestMethod = null): RoutingConfigurator { if (!is_callable($postInterceptor) && !($postInterceptor instanceof PostInterceptor) && !class_exists((string) $postInterceptor)) { throw new \InvalidArgumentException( 'Given pre interceptor must be a callable, an instance of ' . PostInterceptor::class . ' or a class name of an existing post interceptor class' ); } $this->postInterceptors[] = [ 'interceptor' => $postInterceptor, 'requestMethod' => $requestMethod, 'path' => $path ]; return $this; }
[ "public", "function", "postIntercept", "(", "$", "postInterceptor", ",", "string", "$", "path", "=", "null", ",", "string", "$", "requestMethod", "=", "null", ")", ":", "RoutingConfigurator", "{", "if", "(", "!", "is_callable", "(", "$", "postInterceptor", ")", "&&", "!", "(", "$", "postInterceptor", "instanceof", "PostInterceptor", ")", "&&", "!", "class_exists", "(", "(", "string", ")", "$", "postInterceptor", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Given pre interceptor must be a callable, an instance of '", ".", "PostInterceptor", "::", "class", ".", "' or a class name of an existing post interceptor class'", ")", ";", "}", "$", "this", "->", "postInterceptors", "[", "]", "=", "[", "'interceptor'", "=>", "$", "postInterceptor", ",", "'requestMethod'", "=>", "$", "requestMethod", ",", "'path'", "=>", "$", "path", "]", ";", "return", "$", "this", ";", "}" ]
post intercept with given class or callable on all requests @param string|callable|\stubbles\webapp\interceptor\PostInterceptor $postInterceptor post interceptor to add @param string $path optional path for which post interceptor should be executed @param string $requestMethod optional request method for which interceptor should be executed @return \stubbles\webapp\RoutingConfigurator @throws \InvalidArgumentException
[ "post", "intercept", "with", "given", "class", "or", "callable", "on", "all", "requests" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L472-L488
16,502
stubbles/stubbles-webapp-core
src/main/php/routing/Routing.php
Routing.getPreInterceptors
private function getPreInterceptors(CalledUri $calledUri, Route $route = null): array { $global = $this->getApplicable($calledUri, $this->preInterceptors); if (null === $route) { return $global; } return array_merge($global, $route->preInterceptors()); }
php
private function getPreInterceptors(CalledUri $calledUri, Route $route = null): array { $global = $this->getApplicable($calledUri, $this->preInterceptors); if (null === $route) { return $global; } return array_merge($global, $route->preInterceptors()); }
[ "private", "function", "getPreInterceptors", "(", "CalledUri", "$", "calledUri", ",", "Route", "$", "route", "=", "null", ")", ":", "array", "{", "$", "global", "=", "$", "this", "->", "getApplicable", "(", "$", "calledUri", ",", "$", "this", "->", "preInterceptors", ")", ";", "if", "(", "null", "===", "$", "route", ")", "{", "return", "$", "global", ";", "}", "return", "array_merge", "(", "$", "global", ",", "$", "route", "->", "preInterceptors", "(", ")", ")", ";", "}" ]
returns list of applicable pre interceptors for this request @param \stubbles\webapp\routing\CalledUri $calledUri @param \stubbles\webapp\routing\Route $route @return array
[ "returns", "list", "of", "applicable", "pre", "interceptors", "for", "this", "request" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L513-L521
16,503
stubbles/stubbles-webapp-core
src/main/php/routing/Routing.php
Routing.getPostInterceptors
private function getPostInterceptors(CalledUri $calledUri, Route $route = null): array { $global = $this->getApplicable($calledUri, $this->postInterceptors); if (null === $route) { return $global; } return array_merge($route->postInterceptors(), $global); }
php
private function getPostInterceptors(CalledUri $calledUri, Route $route = null): array { $global = $this->getApplicable($calledUri, $this->postInterceptors); if (null === $route) { return $global; } return array_merge($route->postInterceptors(), $global); }
[ "private", "function", "getPostInterceptors", "(", "CalledUri", "$", "calledUri", ",", "Route", "$", "route", "=", "null", ")", ":", "array", "{", "$", "global", "=", "$", "this", "->", "getApplicable", "(", "$", "calledUri", ",", "$", "this", "->", "postInterceptors", ")", ";", "if", "(", "null", "===", "$", "route", ")", "{", "return", "$", "global", ";", "}", "return", "array_merge", "(", "$", "route", "->", "postInterceptors", "(", ")", ",", "$", "global", ")", ";", "}" ]
returns list of applicable post interceptors for this request @param \stubbles\webapp\routing\CalledUri $calledUri @param \stubbles\webapp\routing\Route $route @return array
[ "returns", "list", "of", "applicable", "post", "interceptors", "for", "this", "request" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L530-L538
16,504
stubbles/stubbles-webapp-core
src/main/php/routing/Routing.php
Routing.getApplicable
private function getApplicable(CalledUri $calledUri, array $interceptors): array { $applicable = []; foreach ($interceptors as $interceptor) { if ($calledUri->satisfies($interceptor['requestMethod'], $interceptor['path'])) { $applicable[] = $interceptor['interceptor']; } } return $applicable; }
php
private function getApplicable(CalledUri $calledUri, array $interceptors): array { $applicable = []; foreach ($interceptors as $interceptor) { if ($calledUri->satisfies($interceptor['requestMethod'], $interceptor['path'])) { $applicable[] = $interceptor['interceptor']; } } return $applicable; }
[ "private", "function", "getApplicable", "(", "CalledUri", "$", "calledUri", ",", "array", "$", "interceptors", ")", ":", "array", "{", "$", "applicable", "=", "[", "]", ";", "foreach", "(", "$", "interceptors", "as", "$", "interceptor", ")", "{", "if", "(", "$", "calledUri", "->", "satisfies", "(", "$", "interceptor", "[", "'requestMethod'", "]", ",", "$", "interceptor", "[", "'path'", "]", ")", ")", "{", "$", "applicable", "[", "]", "=", "$", "interceptor", "[", "'interceptor'", "]", ";", "}", "}", "return", "$", "applicable", ";", "}" ]
calculates which interceptors are applicable for given request method @param \stubbles\webapp\routing\CalledUri $calledUri @param array[] $interceptors list of interceptors to check @return array
[ "calculates", "which", "interceptors", "are", "applicable", "for", "given", "request", "method" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L547-L557
16,505
stubbles/stubbles-webapp-core
src/main/php/routing/Routing.php
Routing.setDefaultMimeTypeClass
public function setDefaultMimeTypeClass(string $mimeType, $mimeTypeClass): RoutingConfigurator { SupportedMimeTypes::setDefaultMimeTypeClass($mimeType, $mimeTypeClass); return $this; }
php
public function setDefaultMimeTypeClass(string $mimeType, $mimeTypeClass): RoutingConfigurator { SupportedMimeTypes::setDefaultMimeTypeClass($mimeType, $mimeTypeClass); return $this; }
[ "public", "function", "setDefaultMimeTypeClass", "(", "string", "$", "mimeType", ",", "$", "mimeTypeClass", ")", ":", "RoutingConfigurator", "{", "SupportedMimeTypes", "::", "setDefaultMimeTypeClass", "(", "$", "mimeType", ",", "$", "mimeTypeClass", ")", ";", "return", "$", "this", ";", "}" ]
sets a default mime type class for given mime type, but doesn't mark the mime type as supported for all routes @param string $mimeType mime type to set default class for @param string $mimeTypeClass class to use @return \stubbles\webapp\routing\Routing @since 5.1.0
[ "sets", "a", "default", "mime", "type", "class", "for", "given", "mime", "type", "but", "doesn", "t", "mark", "the", "mime", "type", "as", "supported", "for", "all", "routes" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L567-L571
16,506
stubbles/stubbles-webapp-core
src/main/php/routing/Routing.php
Routing.supportsMimeType
public function supportsMimeType(string $mimeType, $mimeTypeClass = null): RoutingConfigurator { if (null === $mimeTypeClass && !SupportedMimeTypes::provideDefaultClassFor($mimeType)) { throw new \InvalidArgumentException( 'No default class known for mime type ' . $mimeType . ', please provide a class' ); } $this->mimeTypes[] = $mimeType; if (null !== $mimeTypeClass) { $this->mimeTypeClasses[$mimeType] = $mimeTypeClass; } return $this; }
php
public function supportsMimeType(string $mimeType, $mimeTypeClass = null): RoutingConfigurator { if (null === $mimeTypeClass && !SupportedMimeTypes::provideDefaultClassFor($mimeType)) { throw new \InvalidArgumentException( 'No default class known for mime type ' . $mimeType . ', please provide a class' ); } $this->mimeTypes[] = $mimeType; if (null !== $mimeTypeClass) { $this->mimeTypeClasses[$mimeType] = $mimeTypeClass; } return $this; }
[ "public", "function", "supportsMimeType", "(", "string", "$", "mimeType", ",", "$", "mimeTypeClass", "=", "null", ")", ":", "RoutingConfigurator", "{", "if", "(", "null", "===", "$", "mimeTypeClass", "&&", "!", "SupportedMimeTypes", "::", "provideDefaultClassFor", "(", "$", "mimeType", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'No default class known for mime type '", ".", "$", "mimeType", ".", "', please provide a class'", ")", ";", "}", "$", "this", "->", "mimeTypes", "[", "]", "=", "$", "mimeType", ";", "if", "(", "null", "!==", "$", "mimeTypeClass", ")", "{", "$", "this", "->", "mimeTypeClasses", "[", "$", "mimeType", "]", "=", "$", "mimeTypeClass", ";", "}", "return", "$", "this", ";", "}" ]
add a supported mime type @param string $mimeType @param string $mimeTypeClass optional special class to be used for given mime type on this route @return \stubbles\webapp\routing\Routing @throws \InvalidArgumentException
[ "add", "a", "supported", "mime", "type" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L581-L596
16,507
stubbles/stubbles-webapp-core
src/main/php/routing/Routing.php
Routing.supportedMimeTypes
private function supportedMimeTypes(Route $route = null): SupportedMimeTypes { if ($this->disableContentNegotation) { return SupportedMimeTypes::createWithDisabledContentNegotation(); } if (null !== $route) { return $route->supportedMimeTypes( $this->mimeTypes, $this->mimeTypeClasses ); } return new SupportedMimeTypes($this->mimeTypes, $this->mimeTypeClasses); }
php
private function supportedMimeTypes(Route $route = null): SupportedMimeTypes { if ($this->disableContentNegotation) { return SupportedMimeTypes::createWithDisabledContentNegotation(); } if (null !== $route) { return $route->supportedMimeTypes( $this->mimeTypes, $this->mimeTypeClasses ); } return new SupportedMimeTypes($this->mimeTypes, $this->mimeTypeClasses); }
[ "private", "function", "supportedMimeTypes", "(", "Route", "$", "route", "=", "null", ")", ":", "SupportedMimeTypes", "{", "if", "(", "$", "this", "->", "disableContentNegotation", ")", "{", "return", "SupportedMimeTypes", "::", "createWithDisabledContentNegotation", "(", ")", ";", "}", "if", "(", "null", "!==", "$", "route", ")", "{", "return", "$", "route", "->", "supportedMimeTypes", "(", "$", "this", "->", "mimeTypes", ",", "$", "this", "->", "mimeTypeClasses", ")", ";", "}", "return", "new", "SupportedMimeTypes", "(", "$", "this", "->", "mimeTypes", ",", "$", "this", "->", "mimeTypeClasses", ")", ";", "}" ]
retrieves list of supported mime types @param \stubbles\webapp\routing\Route $route @return \stubbles\webapp\routing\SupportedMimeTypes
[ "retrieves", "list", "of", "supported", "mime", "types" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L616-L630
16,508
jan-dolata/crude-crud
src/Engine/CrudeSetup.php
CrudeSetup.getJSData
public function getJSData() { return [ 'name' => $this->name, 'title' => $this->title, 'description' => $this->description, 'column' => $this->column, 'extraColumn' => $this->extraColumn, 'columnFormat' => $this->columnFormat, 'addForm' => $this->addForm, 'editForm' => $this->editForm, 'inputType' => $this->inputType, 'actions' => $this->actions, 'deleteOption' => $this->deleteOption, 'editOption' => $this->editOption, 'addOption' => $this->addOption, 'orderOption' => $this->orderOption, 'exportOption' => $this->exportOption, 'microEditOption' => $this->microEditOption, 'modelDefaults' => $this->modelDefaults, 'selectOptions' => $this->selectOptions, 'filters' => $this->filters, 'richFilters' => $this->richFilters, 'showFilters' => $this->showFilters, 'trans' => $this->trans, 'moduleInPopup' => $this->moduleInPopup, 'customActions' => $this->customActions, 'panelView' => $this->panelView, 'orderParameters' => $this->orderParameters, 'checkboxColumn' => $this->checkboxColumn, 'defaultSortAttr' => $this->defaultSortAttr, 'defaultSortOrder' => $this->defaultSortOrder, 'interfaceTrans' => $this->getInterfaceTrans(), 'thumbnailColumns' => $this->getThumbnailColumns(), 'dateTimePickerOptions' => $this->getDateTimePickerOptions(), 'config' => [ 'routePrefix' => config('crude.routePrefix'), 'numRowsOptions' => config('crude.numRowsOptions'), 'iconClassName' => config('crude.iconClassName'), 'refreshAll' => config('crude.refreshAll'), 'mapCenter' => config('crude.mapCenter'), 'sortAttr' => $this->getOrderAttribute(), ], ]; }
php
public function getJSData() { return [ 'name' => $this->name, 'title' => $this->title, 'description' => $this->description, 'column' => $this->column, 'extraColumn' => $this->extraColumn, 'columnFormat' => $this->columnFormat, 'addForm' => $this->addForm, 'editForm' => $this->editForm, 'inputType' => $this->inputType, 'actions' => $this->actions, 'deleteOption' => $this->deleteOption, 'editOption' => $this->editOption, 'addOption' => $this->addOption, 'orderOption' => $this->orderOption, 'exportOption' => $this->exportOption, 'microEditOption' => $this->microEditOption, 'modelDefaults' => $this->modelDefaults, 'selectOptions' => $this->selectOptions, 'filters' => $this->filters, 'richFilters' => $this->richFilters, 'showFilters' => $this->showFilters, 'trans' => $this->trans, 'moduleInPopup' => $this->moduleInPopup, 'customActions' => $this->customActions, 'panelView' => $this->panelView, 'orderParameters' => $this->orderParameters, 'checkboxColumn' => $this->checkboxColumn, 'defaultSortAttr' => $this->defaultSortAttr, 'defaultSortOrder' => $this->defaultSortOrder, 'interfaceTrans' => $this->getInterfaceTrans(), 'thumbnailColumns' => $this->getThumbnailColumns(), 'dateTimePickerOptions' => $this->getDateTimePickerOptions(), 'config' => [ 'routePrefix' => config('crude.routePrefix'), 'numRowsOptions' => config('crude.numRowsOptions'), 'iconClassName' => config('crude.iconClassName'), 'refreshAll' => config('crude.refreshAll'), 'mapCenter' => config('crude.mapCenter'), 'sortAttr' => $this->getOrderAttribute(), ], ]; }
[ "public", "function", "getJSData", "(", ")", "{", "return", "[", "'name'", "=>", "$", "this", "->", "name", ",", "'title'", "=>", "$", "this", "->", "title", ",", "'description'", "=>", "$", "this", "->", "description", ",", "'column'", "=>", "$", "this", "->", "column", ",", "'extraColumn'", "=>", "$", "this", "->", "extraColumn", ",", "'columnFormat'", "=>", "$", "this", "->", "columnFormat", ",", "'addForm'", "=>", "$", "this", "->", "addForm", ",", "'editForm'", "=>", "$", "this", "->", "editForm", ",", "'inputType'", "=>", "$", "this", "->", "inputType", ",", "'actions'", "=>", "$", "this", "->", "actions", ",", "'deleteOption'", "=>", "$", "this", "->", "deleteOption", ",", "'editOption'", "=>", "$", "this", "->", "editOption", ",", "'addOption'", "=>", "$", "this", "->", "addOption", ",", "'orderOption'", "=>", "$", "this", "->", "orderOption", ",", "'exportOption'", "=>", "$", "this", "->", "exportOption", ",", "'microEditOption'", "=>", "$", "this", "->", "microEditOption", ",", "'modelDefaults'", "=>", "$", "this", "->", "modelDefaults", ",", "'selectOptions'", "=>", "$", "this", "->", "selectOptions", ",", "'filters'", "=>", "$", "this", "->", "filters", ",", "'richFilters'", "=>", "$", "this", "->", "richFilters", ",", "'showFilters'", "=>", "$", "this", "->", "showFilters", ",", "'trans'", "=>", "$", "this", "->", "trans", ",", "'moduleInPopup'", "=>", "$", "this", "->", "moduleInPopup", ",", "'customActions'", "=>", "$", "this", "->", "customActions", ",", "'panelView'", "=>", "$", "this", "->", "panelView", ",", "'orderParameters'", "=>", "$", "this", "->", "orderParameters", ",", "'checkboxColumn'", "=>", "$", "this", "->", "checkboxColumn", ",", "'defaultSortAttr'", "=>", "$", "this", "->", "defaultSortAttr", ",", "'defaultSortOrder'", "=>", "$", "this", "->", "defaultSortOrder", ",", "'interfaceTrans'", "=>", "$", "this", "->", "getInterfaceTrans", "(", ")", ",", "'thumbnailColumns'", "=>", "$", "this", "->", "getThumbnailColumns", "(", ")", ",", "'dateTimePickerOptions'", "=>", "$", "this", "->", "getDateTimePickerOptions", "(", ")", ",", "'config'", "=>", "[", "'routePrefix'", "=>", "config", "(", "'crude.routePrefix'", ")", ",", "'numRowsOptions'", "=>", "config", "(", "'crude.numRowsOptions'", ")", ",", "'iconClassName'", "=>", "config", "(", "'crude.iconClassName'", ")", ",", "'refreshAll'", "=>", "config", "(", "'crude.refreshAll'", ")", ",", "'mapCenter'", "=>", "config", "(", "'crude.mapCenter'", ")", ",", "'sortAttr'", "=>", "$", "this", "->", "getOrderAttribute", "(", ")", ",", "]", ",", "]", ";", "}" ]
Prepare data for JS list config model @return array
[ "Prepare", "data", "for", "JS", "list", "config", "model" ]
9129ea08278835cf5cecfd46a90369226ae6bdd7
https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/CrudeSetup.php#L73-L120
16,509
blast-project/CoreBundle
src/Admin/CoreAdmin.php
CoreAdmin.configureRoutes
protected function configureRoutes(RouteCollection $collection) { parent::configureRoutes($collection); $collection->add('duplicate', $this->getRouterIdParameter() . '/duplicate'); $collection->add('generateEntityCode'); /* Needed or not needed ... * in sonata-project/admin-bundle/Controller/CRUDController.php * the batchAction method * throw exception if the http method is not POST */ if ($collection->get('batch')) { $collection->get('batch')->setMethods(['POST']); } }
php
protected function configureRoutes(RouteCollection $collection) { parent::configureRoutes($collection); $collection->add('duplicate', $this->getRouterIdParameter() . '/duplicate'); $collection->add('generateEntityCode'); /* Needed or not needed ... * in sonata-project/admin-bundle/Controller/CRUDController.php * the batchAction method * throw exception if the http method is not POST */ if ($collection->get('batch')) { $collection->get('batch')->setMethods(['POST']); } }
[ "protected", "function", "configureRoutes", "(", "RouteCollection", "$", "collection", ")", "{", "parent", "::", "configureRoutes", "(", "$", "collection", ")", ";", "$", "collection", "->", "add", "(", "'duplicate'", ",", "$", "this", "->", "getRouterIdParameter", "(", ")", ".", "'/duplicate'", ")", ";", "$", "collection", "->", "add", "(", "'generateEntityCode'", ")", ";", "/* Needed or not needed ...\n * in sonata-project/admin-bundle/Controller/CRUDController.php\n * the batchAction method\n * throw exception if the http method is not POST\n */", "if", "(", "$", "collection", "->", "get", "(", "'batch'", ")", ")", "{", "$", "collection", "->", "get", "(", "'batch'", ")", "->", "setMethods", "(", "[", "'POST'", "]", ")", ";", "}", "}" ]
Configure routes for list actions. @param RouteCollection $collection
[ "Configure", "routes", "for", "list", "actions", "." ]
7a0832758ca14e5bc5d65515532c1220df3930ae
https://github.com/blast-project/CoreBundle/blob/7a0832758ca14e5bc5d65515532c1220df3930ae/src/Admin/CoreAdmin.php#L72-L86
16,510
blast-project/CoreBundle
src/Admin/CoreAdmin.php
CoreAdmin.arrayDepth
private static function arrayDepth($array, $level = 0) { if (!$array) { return $level; } if (!is_array($array)) { return $level; } ++$level; foreach ($array as $key => $value) { if (is_array($value)) { $level = $level < self::arrayDepth($value, $level) ? self::arrayDepth($value, $level) : $level; } } return $level; }
php
private static function arrayDepth($array, $level = 0) { if (!$array) { return $level; } if (!is_array($array)) { return $level; } ++$level; foreach ($array as $key => $value) { if (is_array($value)) { $level = $level < self::arrayDepth($value, $level) ? self::arrayDepth($value, $level) : $level; } } return $level; }
[ "private", "static", "function", "arrayDepth", "(", "$", "array", ",", "$", "level", "=", "0", ")", "{", "if", "(", "!", "$", "array", ")", "{", "return", "$", "level", ";", "}", "if", "(", "!", "is_array", "(", "$", "array", ")", ")", "{", "return", "$", "level", ";", "}", "++", "$", "level", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "level", "=", "$", "level", "<", "self", "::", "arrayDepth", "(", "$", "value", ",", "$", "level", ")", "?", "self", "::", "arrayDepth", "(", "$", "value", ",", "$", "level", ")", ":", "$", "level", ";", "}", "}", "return", "$", "level", ";", "}" ]
Returns the level of depth of an array. @param array $array @param int $level : do not use, just used for recursivity @return int : depth
[ "Returns", "the", "level", "of", "depth", "of", "an", "array", "." ]
7a0832758ca14e5bc5d65515532c1220df3930ae
https://github.com/blast-project/CoreBundle/blob/7a0832758ca14e5bc5d65515532c1220df3930ae/src/Admin/CoreAdmin.php#L216-L234
16,511
blast-project/CoreBundle
src/Admin/CoreAdmin.php
CoreAdmin.bundleExists
public function bundleExists($bundle) { $kernelBundles = $this->getConfigurationPool()->getContainer()->getParameter('kernel.bundles'); if (array_key_exists($bundle, $kernelBundles)) { return true; } if (in_array($bundle, $kernelBundles)) { return true; } return false; }
php
public function bundleExists($bundle) { $kernelBundles = $this->getConfigurationPool()->getContainer()->getParameter('kernel.bundles'); if (array_key_exists($bundle, $kernelBundles)) { return true; } if (in_array($bundle, $kernelBundles)) { return true; } return false; }
[ "public", "function", "bundleExists", "(", "$", "bundle", ")", "{", "$", "kernelBundles", "=", "$", "this", "->", "getConfigurationPool", "(", ")", "->", "getContainer", "(", ")", "->", "getParameter", "(", "'kernel.bundles'", ")", ";", "if", "(", "array_key_exists", "(", "$", "bundle", ",", "$", "kernelBundles", ")", ")", "{", "return", "true", ";", "}", "if", "(", "in_array", "(", "$", "bundle", ",", "$", "kernelBundles", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Checks if a Bundle is installed. @param string $bundle Bundle name or class FQN
[ "Checks", "if", "a", "Bundle", "is", "installed", "." ]
7a0832758ca14e5bc5d65515532c1220df3930ae
https://github.com/blast-project/CoreBundle/blob/7a0832758ca14e5bc5d65515532c1220df3930ae/src/Admin/CoreAdmin.php#L328-L339
16,512
blast-project/CoreBundle
src/Admin/CoreAdmin.php
CoreAdmin.renameFormTab
public function renameFormTab($tabName, $newTabName, $keepOrder = true) { $tabs = $this->getFormTabs(); if (!$tabs) { return; } if (!isset($tabs[$tabName])) { throw new \Exception(sprintf('Tab %s does not exist.', $tabName)); } if (isset($tabs[$newTabName])) { return; } if ($keepOrder) { $keys = array_keys($tabs); $keys[array_search($tabName, $keys)] = $newTabName; $tabs = array_combine($keys, $tabs); } else { $tabs[$newTabName] = $tabs[$tabName]; unset($tabs[$tabName]); } $this->setFormTabs($tabs); }
php
public function renameFormTab($tabName, $newTabName, $keepOrder = true) { $tabs = $this->getFormTabs(); if (!$tabs) { return; } if (!isset($tabs[$tabName])) { throw new \Exception(sprintf('Tab %s does not exist.', $tabName)); } if (isset($tabs[$newTabName])) { return; } if ($keepOrder) { $keys = array_keys($tabs); $keys[array_search($tabName, $keys)] = $newTabName; $tabs = array_combine($keys, $tabs); } else { $tabs[$newTabName] = $tabs[$tabName]; unset($tabs[$tabName]); } $this->setFormTabs($tabs); }
[ "public", "function", "renameFormTab", "(", "$", "tabName", ",", "$", "newTabName", ",", "$", "keepOrder", "=", "true", ")", "{", "$", "tabs", "=", "$", "this", "->", "getFormTabs", "(", ")", ";", "if", "(", "!", "$", "tabs", ")", "{", "return", ";", "}", "if", "(", "!", "isset", "(", "$", "tabs", "[", "$", "tabName", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'Tab %s does not exist.'", ",", "$", "tabName", ")", ")", ";", "}", "if", "(", "isset", "(", "$", "tabs", "[", "$", "newTabName", "]", ")", ")", "{", "return", ";", "}", "if", "(", "$", "keepOrder", ")", "{", "$", "keys", "=", "array_keys", "(", "$", "tabs", ")", ";", "$", "keys", "[", "array_search", "(", "$", "tabName", ",", "$", "keys", ")", "]", "=", "$", "newTabName", ";", "$", "tabs", "=", "array_combine", "(", "$", "keys", ",", "$", "tabs", ")", ";", "}", "else", "{", "$", "tabs", "[", "$", "newTabName", "]", "=", "$", "tabs", "[", "$", "tabName", "]", ";", "unset", "(", "$", "tabs", "[", "$", "tabName", "]", ")", ";", "}", "$", "this", "->", "setFormTabs", "(", "$", "tabs", ")", ";", "}" ]
Rename a form tab after form fields have been configured. TODO: groups of the renamed tab are still prefixed with the old tab name @param type $tabName the name of the tab to be renamed @param type $newTabName the new name for the tab
[ "Rename", "a", "form", "tab", "after", "form", "fields", "have", "been", "configured", "." ]
7a0832758ca14e5bc5d65515532c1220df3930ae
https://github.com/blast-project/CoreBundle/blob/7a0832758ca14e5bc5d65515532c1220df3930ae/src/Admin/CoreAdmin.php#L349-L374
16,513
blast-project/CoreBundle
src/Admin/CoreAdmin.php
CoreAdmin.renameShowTab
public function renameShowTab($tabName, $newTabName, $keepOrder = true) { $tabs = $this->getShowTabs(); if (!$tabs) { return; } if (!isset($tabs[$tabName])) { throw new \Exception(sprintf('Tab %s does not exist.', $tabName)); } if (isset($tabs[$newTabName])) { return; } if ($keepOrder) { $keys = array_keys($tabs); $keys[array_search($tabName, $keys)] = $newTabName; $tabs = array_combine($keys, $tabs); } else { $tabs[$newTabName] = $tabs[$tabName]; unset($tabs[$tabName]); } $this->setShowTabs($tabs); }
php
public function renameShowTab($tabName, $newTabName, $keepOrder = true) { $tabs = $this->getShowTabs(); if (!$tabs) { return; } if (!isset($tabs[$tabName])) { throw new \Exception(sprintf('Tab %s does not exist.', $tabName)); } if (isset($tabs[$newTabName])) { return; } if ($keepOrder) { $keys = array_keys($tabs); $keys[array_search($tabName, $keys)] = $newTabName; $tabs = array_combine($keys, $tabs); } else { $tabs[$newTabName] = $tabs[$tabName]; unset($tabs[$tabName]); } $this->setShowTabs($tabs); }
[ "public", "function", "renameShowTab", "(", "$", "tabName", ",", "$", "newTabName", ",", "$", "keepOrder", "=", "true", ")", "{", "$", "tabs", "=", "$", "this", "->", "getShowTabs", "(", ")", ";", "if", "(", "!", "$", "tabs", ")", "{", "return", ";", "}", "if", "(", "!", "isset", "(", "$", "tabs", "[", "$", "tabName", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'Tab %s does not exist.'", ",", "$", "tabName", ")", ")", ";", "}", "if", "(", "isset", "(", "$", "tabs", "[", "$", "newTabName", "]", ")", ")", "{", "return", ";", "}", "if", "(", "$", "keepOrder", ")", "{", "$", "keys", "=", "array_keys", "(", "$", "tabs", ")", ";", "$", "keys", "[", "array_search", "(", "$", "tabName", ",", "$", "keys", ")", "]", "=", "$", "newTabName", ";", "$", "tabs", "=", "array_combine", "(", "$", "keys", ",", "$", "tabs", ")", ";", "}", "else", "{", "$", "tabs", "[", "$", "newTabName", "]", "=", "$", "tabs", "[", "$", "tabName", "]", ";", "unset", "(", "$", "tabs", "[", "$", "tabName", "]", ")", ";", "}", "$", "this", "->", "setShowTabs", "(", "$", "tabs", ")", ";", "}" ]
Rename a show tab after show fields have been configured. TODO: groups of the renamed tab are still prefixed with the old tab name @param type $tabName the name of the tab to be renamed @param type $newTabName the new name for the tab
[ "Rename", "a", "show", "tab", "after", "show", "fields", "have", "been", "configured", "." ]
7a0832758ca14e5bc5d65515532c1220df3930ae
https://github.com/blast-project/CoreBundle/blob/7a0832758ca14e5bc5d65515532c1220df3930ae/src/Admin/CoreAdmin.php#L384-L409
16,514
blast-project/CoreBundle
src/Admin/CoreAdmin.php
CoreAdmin.removeTab
public function removeTab($tabNames, $mapper) { $currentTabs = $this->getFormTabs(); foreach ($currentTabs as $k => $item) { if (is_array($tabNames) && in_array($item['name'], $tabNames) || !is_array($tabNames) && $item['name'] === $tabNames) { foreach ($item['groups'] as $groupName) { $this->removeAllFieldsFromFormGroup($groupName, $mapper); } unset($currentTabs[$k]); } } $this->setFormTabs($currentTabs); }
php
public function removeTab($tabNames, $mapper) { $currentTabs = $this->getFormTabs(); foreach ($currentTabs as $k => $item) { if (is_array($tabNames) && in_array($item['name'], $tabNames) || !is_array($tabNames) && $item['name'] === $tabNames) { foreach ($item['groups'] as $groupName) { $this->removeAllFieldsFromFormGroup($groupName, $mapper); } unset($currentTabs[$k]); } } $this->setFormTabs($currentTabs); }
[ "public", "function", "removeTab", "(", "$", "tabNames", ",", "$", "mapper", ")", "{", "$", "currentTabs", "=", "$", "this", "->", "getFormTabs", "(", ")", ";", "foreach", "(", "$", "currentTabs", "as", "$", "k", "=>", "$", "item", ")", "{", "if", "(", "is_array", "(", "$", "tabNames", ")", "&&", "in_array", "(", "$", "item", "[", "'name'", "]", ",", "$", "tabNames", ")", "||", "!", "is_array", "(", "$", "tabNames", ")", "&&", "$", "item", "[", "'name'", "]", "===", "$", "tabNames", ")", "{", "foreach", "(", "$", "item", "[", "'groups'", "]", "as", "$", "groupName", ")", "{", "$", "this", "->", "removeAllFieldsFromFormGroup", "(", "$", "groupName", ",", "$", "mapper", ")", ";", "}", "unset", "(", "$", "currentTabs", "[", "$", "k", "]", ")", ";", "}", "}", "$", "this", "->", "setFormTabs", "(", "$", "currentTabs", ")", ";", "}" ]
Removes tab in current form Mapper. @param string|array $tabNames name or array of names of tabs to be removed @param FormMapper $mapper Sonata Admin form mapper
[ "Removes", "tab", "in", "current", "form", "Mapper", "." ]
7a0832758ca14e5bc5d65515532c1220df3930ae
https://github.com/blast-project/CoreBundle/blob/7a0832758ca14e5bc5d65515532c1220df3930ae/src/Admin/CoreAdmin.php#L460-L472
16,515
blast-project/CoreBundle
src/Admin/CoreAdmin.php
CoreAdmin.removeAllFieldsFromFormGroup
public function removeAllFieldsFromFormGroup($groupName, $mapper) { $formGroups = $this->getFormGroups(); foreach ($formGroups as $name => $formGroup) { if ($name === $groupName) { foreach ($formGroups[$name]['fields'] as $key => $field) { $mapper->remove($key); } } } }
php
public function removeAllFieldsFromFormGroup($groupName, $mapper) { $formGroups = $this->getFormGroups(); foreach ($formGroups as $name => $formGroup) { if ($name === $groupName) { foreach ($formGroups[$name]['fields'] as $key => $field) { $mapper->remove($key); } } } }
[ "public", "function", "removeAllFieldsFromFormGroup", "(", "$", "groupName", ",", "$", "mapper", ")", "{", "$", "formGroups", "=", "$", "this", "->", "getFormGroups", "(", ")", ";", "foreach", "(", "$", "formGroups", "as", "$", "name", "=>", "$", "formGroup", ")", "{", "if", "(", "$", "name", "===", "$", "groupName", ")", "{", "foreach", "(", "$", "formGroups", "[", "$", "name", "]", "[", "'fields'", "]", "as", "$", "key", "=>", "$", "field", ")", "{", "$", "mapper", "->", "remove", "(", "$", "key", ")", ";", "}", "}", "}", "}" ]
Removes all fields from form groups and remove them from mapper. @param string $groupName Name of the group to remove @param FormMapper $mapper Sonata Admin form mapper
[ "Removes", "all", "fields", "from", "form", "groups", "and", "remove", "them", "from", "mapper", "." ]
7a0832758ca14e5bc5d65515532c1220df3930ae
https://github.com/blast-project/CoreBundle/blob/7a0832758ca14e5bc5d65515532c1220df3930ae/src/Admin/CoreAdmin.php#L480-L490
16,516
ekyna/GlsUniBox
Api/Response.php
Response.create
public static function create($body) { if (0 !== strpos($body, static::START_TOKEN)) { throw new InvalidArgumentException("Unexpected response body."); } if (static::END_TOKEN !== substr($body, -strlen(static::END_TOKEN))) { throw new InvalidArgumentException("Unexpected response body."); } $body = substr($body, strlen(static::START_TOKEN), -strlen(static::END_TOKEN)); $parts = explode('|', trim($body, '|')); if (empty($parts)) { throw new InvalidArgumentException("Unexpected response body."); } $response = new static(); for ($i = 0; $i < count($parts); $i++) { list($key, $value) = explode(':', $parts[$i], 2); if ($key === Config::RESULT) { if (0 < strpos($value, ':')) { list($code, $field) = explode(':', $value, 2); } else { $code = $value; $field = 'unknown'; } $response->set(Config::RESULT, $code); $response->set(Config::FIELD, $field); } else { $response->set($key, $value); } } return $response; }
php
public static function create($body) { if (0 !== strpos($body, static::START_TOKEN)) { throw new InvalidArgumentException("Unexpected response body."); } if (static::END_TOKEN !== substr($body, -strlen(static::END_TOKEN))) { throw new InvalidArgumentException("Unexpected response body."); } $body = substr($body, strlen(static::START_TOKEN), -strlen(static::END_TOKEN)); $parts = explode('|', trim($body, '|')); if (empty($parts)) { throw new InvalidArgumentException("Unexpected response body."); } $response = new static(); for ($i = 0; $i < count($parts); $i++) { list($key, $value) = explode(':', $parts[$i], 2); if ($key === Config::RESULT) { if (0 < strpos($value, ':')) { list($code, $field) = explode(':', $value, 2); } else { $code = $value; $field = 'unknown'; } $response->set(Config::RESULT, $code); $response->set(Config::FIELD, $field); } else { $response->set($key, $value); } } return $response; }
[ "public", "static", "function", "create", "(", "$", "body", ")", "{", "if", "(", "0", "!==", "strpos", "(", "$", "body", ",", "static", "::", "START_TOKEN", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Unexpected response body.\"", ")", ";", "}", "if", "(", "static", "::", "END_TOKEN", "!==", "substr", "(", "$", "body", ",", "-", "strlen", "(", "static", "::", "END_TOKEN", ")", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Unexpected response body.\"", ")", ";", "}", "$", "body", "=", "substr", "(", "$", "body", ",", "strlen", "(", "static", "::", "START_TOKEN", ")", ",", "-", "strlen", "(", "static", "::", "END_TOKEN", ")", ")", ";", "$", "parts", "=", "explode", "(", "'|'", ",", "trim", "(", "$", "body", ",", "'|'", ")", ")", ";", "if", "(", "empty", "(", "$", "parts", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Unexpected response body.\"", ")", ";", "}", "$", "response", "=", "new", "static", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "parts", ")", ";", "$", "i", "++", ")", "{", "list", "(", "$", "key", ",", "$", "value", ")", "=", "explode", "(", "':'", ",", "$", "parts", "[", "$", "i", "]", ",", "2", ")", ";", "if", "(", "$", "key", "===", "Config", "::", "RESULT", ")", "{", "if", "(", "0", "<", "strpos", "(", "$", "value", ",", "':'", ")", ")", "{", "list", "(", "$", "code", ",", "$", "field", ")", "=", "explode", "(", "':'", ",", "$", "value", ",", "2", ")", ";", "}", "else", "{", "$", "code", "=", "$", "value", ";", "$", "field", "=", "'unknown'", ";", "}", "$", "response", "->", "set", "(", "Config", "::", "RESULT", ",", "$", "code", ")", ";", "$", "response", "->", "set", "(", "Config", "::", "FIELD", ",", "$", "field", ")", ";", "}", "else", "{", "$", "response", "->", "set", "(", "$", "key", ",", "$", "value", ")", ";", "}", "}", "return", "$", "response", ";", "}" ]
Creates a response from the given http response body. @param string $body @return Response
[ "Creates", "a", "response", "from", "the", "given", "http", "response", "body", "." ]
b474271ba355c3917074422306dc64abf09584d0
https://github.com/ekyna/GlsUniBox/blob/b474271ba355c3917074422306dc64abf09584d0/Api/Response.php#L27-L63
16,517
harp-orm/query
src/Compiler/Join.php
Join.render
public static function render(SQL\Join $join) { $condition = $join->getCondition(); $table = $join->getTable(); return Compiler::expression(array( $join->getType(), 'JOIN', $table instanceof SQL\Aliased ? Aliased::render($table) : $table, is_array($condition) ? self::renderArrayCondition($condition) : $condition, )); }
php
public static function render(SQL\Join $join) { $condition = $join->getCondition(); $table = $join->getTable(); return Compiler::expression(array( $join->getType(), 'JOIN', $table instanceof SQL\Aliased ? Aliased::render($table) : $table, is_array($condition) ? self::renderArrayCondition($condition) : $condition, )); }
[ "public", "static", "function", "render", "(", "SQL", "\\", "Join", "$", "join", ")", "{", "$", "condition", "=", "$", "join", "->", "getCondition", "(", ")", ";", "$", "table", "=", "$", "join", "->", "getTable", "(", ")", ";", "return", "Compiler", "::", "expression", "(", "array", "(", "$", "join", "->", "getType", "(", ")", ",", "'JOIN'", ",", "$", "table", "instanceof", "SQL", "\\", "Aliased", "?", "Aliased", "::", "render", "(", "$", "table", ")", ":", "$", "table", ",", "is_array", "(", "$", "condition", ")", "?", "self", "::", "renderArrayCondition", "(", "$", "condition", ")", ":", "$", "condition", ",", ")", ")", ";", "}" ]
Render a Join object @param SQL\Join $join @return string
[ "Render", "a", "Join", "object" ]
98ce2468a0a31fe15ed3692bad32547bf6dbe41a
https://github.com/harp-orm/query/blob/98ce2468a0a31fe15ed3692bad32547bf6dbe41a/src/Compiler/Join.php#L50-L61
16,518
discophp/framework
core/classes/Controller.class.php
Controller.template
public function template($template, $data = Array()){ \Template::with($template, $data); \View::serve(); }
php
public function template($template, $data = Array()){ \Template::with($template, $data); \View::serve(); }
[ "public", "function", "template", "(", "$", "template", ",", "$", "data", "=", "Array", "(", ")", ")", "{", "\\", "Template", "::", "with", "(", "$", "template", ",", "$", "data", ")", ";", "\\", "View", "::", "serve", "(", ")", ";", "}" ]
A template to add to the view and return. @param string $template The template name to load into the view. @param array $data The data to bind into the template. Defaults to empty array.
[ "A", "template", "to", "add", "to", "the", "view", "and", "return", "." ]
40ff3ea5225810534195494dc6c21083da4d1356
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/Controller.class.php#L42-L45
16,519
VDMi/Guzzle-oAuth
src/GuzzleOauth/BaseConsumerOauth2.php
BaseConsumerOauth2.getAuthorizeUrl
public function getAuthorizeUrl($request_token, $callback_uri = NULL, $state = NULL) { if (empty($callback_uri) && isset($request_token['callback_uri'])) { $callback_uri = $request_token['callback_uri']; } if (empty($state)) { $state = md5(mt_rand()); } $params = array(); if ($this->getConfig()->get('offline_access')) { $params += $this->getOfflineAccessParams(); } $query = array( 'response_type' => 'code', 'client_id' => $this->getConfig('consumer_key'), 'redirect_uri' => $callback_uri, 'scope' => implode($this->getConfig('scope_delimiter'), $this->getScope()), 'state' => $state, ) + $params; // authorize $url = Url::factory($this->getConfig('base_url')); $url->addPath($this->getConfig('authorize_path')); $url->setQuery($query); return (string)$url; }
php
public function getAuthorizeUrl($request_token, $callback_uri = NULL, $state = NULL) { if (empty($callback_uri) && isset($request_token['callback_uri'])) { $callback_uri = $request_token['callback_uri']; } if (empty($state)) { $state = md5(mt_rand()); } $params = array(); if ($this->getConfig()->get('offline_access')) { $params += $this->getOfflineAccessParams(); } $query = array( 'response_type' => 'code', 'client_id' => $this->getConfig('consumer_key'), 'redirect_uri' => $callback_uri, 'scope' => implode($this->getConfig('scope_delimiter'), $this->getScope()), 'state' => $state, ) + $params; // authorize $url = Url::factory($this->getConfig('base_url')); $url->addPath($this->getConfig('authorize_path')); $url->setQuery($query); return (string)$url; }
[ "public", "function", "getAuthorizeUrl", "(", "$", "request_token", ",", "$", "callback_uri", "=", "NULL", ",", "$", "state", "=", "NULL", ")", "{", "if", "(", "empty", "(", "$", "callback_uri", ")", "&&", "isset", "(", "$", "request_token", "[", "'callback_uri'", "]", ")", ")", "{", "$", "callback_uri", "=", "$", "request_token", "[", "'callback_uri'", "]", ";", "}", "if", "(", "empty", "(", "$", "state", ")", ")", "{", "$", "state", "=", "md5", "(", "mt_rand", "(", ")", ")", ";", "}", "$", "params", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "getConfig", "(", ")", "->", "get", "(", "'offline_access'", ")", ")", "{", "$", "params", "+=", "$", "this", "->", "getOfflineAccessParams", "(", ")", ";", "}", "$", "query", "=", "array", "(", "'response_type'", "=>", "'code'", ",", "'client_id'", "=>", "$", "this", "->", "getConfig", "(", "'consumer_key'", ")", ",", "'redirect_uri'", "=>", "$", "callback_uri", ",", "'scope'", "=>", "implode", "(", "$", "this", "->", "getConfig", "(", "'scope_delimiter'", ")", ",", "$", "this", "->", "getScope", "(", ")", ")", ",", "'state'", "=>", "$", "state", ",", ")", "+", "$", "params", ";", "// authorize", "$", "url", "=", "Url", "::", "factory", "(", "$", "this", "->", "getConfig", "(", "'base_url'", ")", ")", ";", "$", "url", "->", "addPath", "(", "$", "this", "->", "getConfig", "(", "'authorize_path'", ")", ")", ";", "$", "url", "->", "setQuery", "(", "$", "query", ")", ";", "return", "(", "string", ")", "$", "url", ";", "}" ]
Return a redirect url.
[ "Return", "a", "redirect", "url", "." ]
e2b2561e4e402e13ba605082bf768b29942f90cb
https://github.com/VDMi/Guzzle-oAuth/blob/e2b2561e4e402e13ba605082bf768b29942f90cb/src/GuzzleOauth/BaseConsumerOauth2.php#L75-L99
16,520
VDMi/Guzzle-oAuth
src/GuzzleOauth/BaseConsumerOauth2.php
BaseConsumerOauth2.normalizeAccessToken
protected function normalizeAccessToken($access_token) { if (!isset($access_token['token_type'])) { $access_token['token_type'] = 'Bearer'; } if (!isset($access_token['expires_at']) && isset($access_token['expires_in'])) { $access_token['expires_at'] = $access_token['expires_in'] + $access_token['request_time']; } return $access_token; }
php
protected function normalizeAccessToken($access_token) { if (!isset($access_token['token_type'])) { $access_token['token_type'] = 'Bearer'; } if (!isset($access_token['expires_at']) && isset($access_token['expires_in'])) { $access_token['expires_at'] = $access_token['expires_in'] + $access_token['request_time']; } return $access_token; }
[ "protected", "function", "normalizeAccessToken", "(", "$", "access_token", ")", "{", "if", "(", "!", "isset", "(", "$", "access_token", "[", "'token_type'", "]", ")", ")", "{", "$", "access_token", "[", "'token_type'", "]", "=", "'Bearer'", ";", "}", "if", "(", "!", "isset", "(", "$", "access_token", "[", "'expires_at'", "]", ")", "&&", "isset", "(", "$", "access_token", "[", "'expires_in'", "]", ")", ")", "{", "$", "access_token", "[", "'expires_at'", "]", "=", "$", "access_token", "[", "'expires_in'", "]", "+", "$", "access_token", "[", "'request_time'", "]", ";", "}", "return", "$", "access_token", ";", "}" ]
Normalize access token
[ "Normalize", "access", "token" ]
e2b2561e4e402e13ba605082bf768b29942f90cb
https://github.com/VDMi/Guzzle-oAuth/blob/e2b2561e4e402e13ba605082bf768b29942f90cb/src/GuzzleOauth/BaseConsumerOauth2.php#L153-L161
16,521
phramework/jsonapi
src/Model/Relationship.php
Relationship.getRelationshipData
public static function getRelationshipData( $relationshipKey, $id, Fields $fields = null, $primaryDataParameters = [], $relationshipParameters = [] ) { if (!static::relationshipExists($relationshipKey)) { throw new \Phramework\Exceptions\ServerException(sprintf( '"%s" is not a valid relationship key', $relationshipKey )); } $relationship = static::getRelationship($relationshipKey); switch ($relationship->type) { case \Phramework\JSONAPI\Relationship::TYPE_TO_ONE: $resource = $callMethod = static::getById( $id, $fields, ...$primaryDataParameters ); if (!$resource) { return null; } //And use it's relationships data for this relationship return ( isset($resource->relationships->{$relationshipKey}->data) ? $resource->relationships->{$relationshipKey}->data : null ); case \Phramework\JSONAPI\Relationship::TYPE_TO_MANY: default: if (!isset($relationship->callbacks->{Phramework::METHOD_GET})) { return []; } $callMethod = $relationship->callbacks->{Phramework::METHOD_GET}; if (!is_callable($callMethod)) { throw new \Phramework\Exceptions\ServerException( $callMethod[0] . '::' . $callMethod[1] . ' is not implemented' ); } //also we could attempt to use getById like the above TO_ONE //to use relationships data return call_user_func( $callMethod, $id, $fields, ...$relationshipParameters ); } }
php
public static function getRelationshipData( $relationshipKey, $id, Fields $fields = null, $primaryDataParameters = [], $relationshipParameters = [] ) { if (!static::relationshipExists($relationshipKey)) { throw new \Phramework\Exceptions\ServerException(sprintf( '"%s" is not a valid relationship key', $relationshipKey )); } $relationship = static::getRelationship($relationshipKey); switch ($relationship->type) { case \Phramework\JSONAPI\Relationship::TYPE_TO_ONE: $resource = $callMethod = static::getById( $id, $fields, ...$primaryDataParameters ); if (!$resource) { return null; } //And use it's relationships data for this relationship return ( isset($resource->relationships->{$relationshipKey}->data) ? $resource->relationships->{$relationshipKey}->data : null ); case \Phramework\JSONAPI\Relationship::TYPE_TO_MANY: default: if (!isset($relationship->callbacks->{Phramework::METHOD_GET})) { return []; } $callMethod = $relationship->callbacks->{Phramework::METHOD_GET}; if (!is_callable($callMethod)) { throw new \Phramework\Exceptions\ServerException( $callMethod[0] . '::' . $callMethod[1] . ' is not implemented' ); } //also we could attempt to use getById like the above TO_ONE //to use relationships data return call_user_func( $callMethod, $id, $fields, ...$relationshipParameters ); } }
[ "public", "static", "function", "getRelationshipData", "(", "$", "relationshipKey", ",", "$", "id", ",", "Fields", "$", "fields", "=", "null", ",", "$", "primaryDataParameters", "=", "[", "]", ",", "$", "relationshipParameters", "=", "[", "]", ")", "{", "if", "(", "!", "static", "::", "relationshipExists", "(", "$", "relationshipKey", ")", ")", "{", "throw", "new", "\\", "Phramework", "\\", "Exceptions", "\\", "ServerException", "(", "sprintf", "(", "'\"%s\" is not a valid relationship key'", ",", "$", "relationshipKey", ")", ")", ";", "}", "$", "relationship", "=", "static", "::", "getRelationship", "(", "$", "relationshipKey", ")", ";", "switch", "(", "$", "relationship", "->", "type", ")", "{", "case", "\\", "Phramework", "\\", "JSONAPI", "\\", "Relationship", "::", "TYPE_TO_ONE", ":", "$", "resource", "=", "$", "callMethod", "=", "static", "::", "getById", "(", "$", "id", ",", "$", "fields", ",", "...", "$", "primaryDataParameters", ")", ";", "if", "(", "!", "$", "resource", ")", "{", "return", "null", ";", "}", "//And use it's relationships data for this relationship", "return", "(", "isset", "(", "$", "resource", "->", "relationships", "->", "{", "$", "relationshipKey", "}", "->", "data", ")", "?", "$", "resource", "->", "relationships", "->", "{", "$", "relationshipKey", "}", "->", "data", ":", "null", ")", ";", "case", "\\", "Phramework", "\\", "JSONAPI", "\\", "Relationship", "::", "TYPE_TO_MANY", ":", "default", ":", "if", "(", "!", "isset", "(", "$", "relationship", "->", "callbacks", "->", "{", "Phramework", "::", "METHOD_GET", "}", ")", ")", "{", "return", "[", "]", ";", "}", "$", "callMethod", "=", "$", "relationship", "->", "callbacks", "->", "{", "Phramework", "::", "METHOD_GET", "}", ";", "if", "(", "!", "is_callable", "(", "$", "callMethod", ")", ")", "{", "throw", "new", "\\", "Phramework", "\\", "Exceptions", "\\", "ServerException", "(", "$", "callMethod", "[", "0", "]", ".", "'::'", ".", "$", "callMethod", "[", "1", "]", ".", "' is not implemented'", ")", ";", "}", "//also we could attempt to use getById like the above TO_ONE", "//to use relationships data", "return", "call_user_func", "(", "$", "callMethod", ",", "$", "id", ",", "$", "fields", ",", "...", "$", "relationshipParameters", ")", ";", "}", "}" ]
Get records from a relationship link @param string $relationshipKey @param string $id @param Fields|null $fields @return RelationshipResource|RelationshipResource[] @throws \Phramework\Exceptions\ServerException If relationship doesn't exist @throws \Phramework\Exceptions\ServerException If relationship's class method is not defined
[ "Get", "records", "from", "a", "relationship", "link" ]
af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726
https://github.com/phramework/jsonapi/blob/af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726/src/Model/Relationship.php#L69-L128
16,522
phramework/jsonapi
src/Model/Relationship.php
Relationship.getIncludedData
public static function getIncludedData( $primaryData, $include = [], Fields $fields = null, $additionalResourceParameters = [] ) { /** * Store relationshipKeys as key and ids of their related data as value * @example * ```php * (object) [ * 'author' => [1], * 'comment' => [1, 2, 3, 4] * ] * ``` */ $tempRelationshipIds = new \stdClass(); //check if relationship exists foreach ($include as $relationshipKey) { if (!static::relationshipExists($relationshipKey)) { throw new RequestException(sprintf( 'Relationship "%s" not found', $relationshipKey )); } //Will hold ids of related data $tempRelationshipIds->{$relationshipKey} = []; } if (empty($include) || empty($primaryData)) { return []; } //iterate all primary data //if a single resource convert it to array //so it can be iterated in the same way if (!is_array($primaryData)) { $primaryData = [$primaryData]; } foreach ($primaryData as $resource) { //Ignore resource if it's relationships are not set or empty if (empty($resource->relationships)) { continue; } foreach ($include as $relationshipKey) { //ignore if requested relationship is not set if (!isset($resource->relationships->{$relationshipKey})) { continue; } //ignore if requested relationship data are not set if (!isset($resource->relationships->{$relationshipKey}->data)) { continue; } $relationshipData = $resource->relationships->{$relationshipKey}->data; if (!$relationshipData || empty($relationshipData)) { continue; } //if single relationship resource convert it to array //so it can be iterated in the same way if (!is_array($relationshipData)) { $relationshipData = [$relationshipData]; } //Push relationship id for this requested relationship foreach ($relationshipData as $primaryKeyAndType) { //push primary key (use type? $primaryKeyAndType->type) $tempRelationshipIds->{$relationshipKey}[] = $primaryKeyAndType->id; } } } $included = []; foreach ($include as $relationshipKey) { $relationship = static::getRelationship($relationshipKey); $relationshipModelClass = $relationship->modelClass; $ids = array_unique($tempRelationshipIds->{$relationshipKey}); $additionalArgument = ( isset($additionalResourceParameters[$relationshipKey]) ? $additionalResourceParameters[$relationshipKey] : [] ); $resources = $relationshipModelClass::getById( $ids, $fields, ...$additionalArgument ); foreach ($resources as $key => $resource) { if ($resource === null) { continue; } $included[] = $resource; } } return $included; }
php
public static function getIncludedData( $primaryData, $include = [], Fields $fields = null, $additionalResourceParameters = [] ) { /** * Store relationshipKeys as key and ids of their related data as value * @example * ```php * (object) [ * 'author' => [1], * 'comment' => [1, 2, 3, 4] * ] * ``` */ $tempRelationshipIds = new \stdClass(); //check if relationship exists foreach ($include as $relationshipKey) { if (!static::relationshipExists($relationshipKey)) { throw new RequestException(sprintf( 'Relationship "%s" not found', $relationshipKey )); } //Will hold ids of related data $tempRelationshipIds->{$relationshipKey} = []; } if (empty($include) || empty($primaryData)) { return []; } //iterate all primary data //if a single resource convert it to array //so it can be iterated in the same way if (!is_array($primaryData)) { $primaryData = [$primaryData]; } foreach ($primaryData as $resource) { //Ignore resource if it's relationships are not set or empty if (empty($resource->relationships)) { continue; } foreach ($include as $relationshipKey) { //ignore if requested relationship is not set if (!isset($resource->relationships->{$relationshipKey})) { continue; } //ignore if requested relationship data are not set if (!isset($resource->relationships->{$relationshipKey}->data)) { continue; } $relationshipData = $resource->relationships->{$relationshipKey}->data; if (!$relationshipData || empty($relationshipData)) { continue; } //if single relationship resource convert it to array //so it can be iterated in the same way if (!is_array($relationshipData)) { $relationshipData = [$relationshipData]; } //Push relationship id for this requested relationship foreach ($relationshipData as $primaryKeyAndType) { //push primary key (use type? $primaryKeyAndType->type) $tempRelationshipIds->{$relationshipKey}[] = $primaryKeyAndType->id; } } } $included = []; foreach ($include as $relationshipKey) { $relationship = static::getRelationship($relationshipKey); $relationshipModelClass = $relationship->modelClass; $ids = array_unique($tempRelationshipIds->{$relationshipKey}); $additionalArgument = ( isset($additionalResourceParameters[$relationshipKey]) ? $additionalResourceParameters[$relationshipKey] : [] ); $resources = $relationshipModelClass::getById( $ids, $fields, ...$additionalArgument ); foreach ($resources as $key => $resource) { if ($resource === null) { continue; } $included[] = $resource; } } return $included; }
[ "public", "static", "function", "getIncludedData", "(", "$", "primaryData", ",", "$", "include", "=", "[", "]", ",", "Fields", "$", "fields", "=", "null", ",", "$", "additionalResourceParameters", "=", "[", "]", ")", "{", "/**\n * Store relationshipKeys as key and ids of their related data as value\n * @example\n * ```php\n * (object) [\n * 'author' => [1],\n * 'comment' => [1, 2, 3, 4]\n * ]\n * ```\n */", "$", "tempRelationshipIds", "=", "new", "\\", "stdClass", "(", ")", ";", "//check if relationship exists", "foreach", "(", "$", "include", "as", "$", "relationshipKey", ")", "{", "if", "(", "!", "static", "::", "relationshipExists", "(", "$", "relationshipKey", ")", ")", "{", "throw", "new", "RequestException", "(", "sprintf", "(", "'Relationship \"%s\" not found'", ",", "$", "relationshipKey", ")", ")", ";", "}", "//Will hold ids of related data", "$", "tempRelationshipIds", "->", "{", "$", "relationshipKey", "}", "=", "[", "]", ";", "}", "if", "(", "empty", "(", "$", "include", ")", "||", "empty", "(", "$", "primaryData", ")", ")", "{", "return", "[", "]", ";", "}", "//iterate all primary data", "//if a single resource convert it to array", "//so it can be iterated in the same way", "if", "(", "!", "is_array", "(", "$", "primaryData", ")", ")", "{", "$", "primaryData", "=", "[", "$", "primaryData", "]", ";", "}", "foreach", "(", "$", "primaryData", "as", "$", "resource", ")", "{", "//Ignore resource if it's relationships are not set or empty", "if", "(", "empty", "(", "$", "resource", "->", "relationships", ")", ")", "{", "continue", ";", "}", "foreach", "(", "$", "include", "as", "$", "relationshipKey", ")", "{", "//ignore if requested relationship is not set", "if", "(", "!", "isset", "(", "$", "resource", "->", "relationships", "->", "{", "$", "relationshipKey", "}", ")", ")", "{", "continue", ";", "}", "//ignore if requested relationship data are not set", "if", "(", "!", "isset", "(", "$", "resource", "->", "relationships", "->", "{", "$", "relationshipKey", "}", "->", "data", ")", ")", "{", "continue", ";", "}", "$", "relationshipData", "=", "$", "resource", "->", "relationships", "->", "{", "$", "relationshipKey", "}", "->", "data", ";", "if", "(", "!", "$", "relationshipData", "||", "empty", "(", "$", "relationshipData", ")", ")", "{", "continue", ";", "}", "//if single relationship resource convert it to array", "//so it can be iterated in the same way", "if", "(", "!", "is_array", "(", "$", "relationshipData", ")", ")", "{", "$", "relationshipData", "=", "[", "$", "relationshipData", "]", ";", "}", "//Push relationship id for this requested relationship", "foreach", "(", "$", "relationshipData", "as", "$", "primaryKeyAndType", ")", "{", "//push primary key (use type? $primaryKeyAndType->type)", "$", "tempRelationshipIds", "->", "{", "$", "relationshipKey", "}", "[", "]", "=", "$", "primaryKeyAndType", "->", "id", ";", "}", "}", "}", "$", "included", "=", "[", "]", ";", "foreach", "(", "$", "include", "as", "$", "relationshipKey", ")", "{", "$", "relationship", "=", "static", "::", "getRelationship", "(", "$", "relationshipKey", ")", ";", "$", "relationshipModelClass", "=", "$", "relationship", "->", "modelClass", ";", "$", "ids", "=", "array_unique", "(", "$", "tempRelationshipIds", "->", "{", "$", "relationshipKey", "}", ")", ";", "$", "additionalArgument", "=", "(", "isset", "(", "$", "additionalResourceParameters", "[", "$", "relationshipKey", "]", ")", "?", "$", "additionalResourceParameters", "[", "$", "relationshipKey", "]", ":", "[", "]", ")", ";", "$", "resources", "=", "$", "relationshipModelClass", "::", "getById", "(", "$", "ids", ",", "$", "fields", ",", "...", "$", "additionalArgument", ")", ";", "foreach", "(", "$", "resources", "as", "$", "key", "=>", "$", "resource", ")", "{", "if", "(", "$", "resource", "===", "null", ")", "{", "continue", ";", "}", "$", "included", "[", "]", "=", "$", "resource", ";", "}", "}", "return", "$", "included", ";", "}" ]
Get jsonapi's included object, selected by include argument, using id's of relationship's data from resources in primary data object @param Resource|Resource[] $primaryData Primary data resource or resources @param string[] $include An array with the keys of relationships to include @param Fields|null $fields @param array $additionalResourceParameters *[Optional]* @return Resource[] An array with all included related data @throws \Phramework\Exceptions\RequestException When a relationship is not found @throws \Phramework\Exceptions\ServerException @todo handle Relationship resource cannot be accessed @todo include second level relationships @example ```php Relationship::getIncludedData( Article::get(), ['tag', 'author'] ); ```
[ "Get", "jsonapi", "s", "included", "object", "selected", "by", "include", "argument", "using", "id", "s", "of", "relationship", "s", "data", "from", "resources", "in", "primary", "data", "object" ]
af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726
https://github.com/phramework/jsonapi/blob/af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726/src/Model/Relationship.php#L150-L261
16,523
acasademont/wurfl
WURFL/WURFLManagerFactory.php
WURFL_WURFLManagerFactory.deviceRepository
private function deviceRepository($persistenceStorage, $userAgentHandlerChain) { $devicePatcher = new WURFL_Xml_DevicePatcher(); $deviceRepositoryBuilder = new WURFL_DeviceRepositoryBuilder($persistenceStorage, $userAgentHandlerChain, $devicePatcher); return $deviceRepositoryBuilder->build($this->wurflConfig->wurflFile, $this->wurflConfig->wurflPatches, $this->wurflConfig->capabilityFilter); }
php
private function deviceRepository($persistenceStorage, $userAgentHandlerChain) { $devicePatcher = new WURFL_Xml_DevicePatcher(); $deviceRepositoryBuilder = new WURFL_DeviceRepositoryBuilder($persistenceStorage, $userAgentHandlerChain, $devicePatcher); return $deviceRepositoryBuilder->build($this->wurflConfig->wurflFile, $this->wurflConfig->wurflPatches, $this->wurflConfig->capabilityFilter); }
[ "private", "function", "deviceRepository", "(", "$", "persistenceStorage", ",", "$", "userAgentHandlerChain", ")", "{", "$", "devicePatcher", "=", "new", "WURFL_Xml_DevicePatcher", "(", ")", ";", "$", "deviceRepositoryBuilder", "=", "new", "WURFL_DeviceRepositoryBuilder", "(", "$", "persistenceStorage", ",", "$", "userAgentHandlerChain", ",", "$", "devicePatcher", ")", ";", "return", "$", "deviceRepositoryBuilder", "->", "build", "(", "$", "this", "->", "wurflConfig", "->", "wurflFile", ",", "$", "this", "->", "wurflConfig", "->", "wurflPatches", ",", "$", "this", "->", "wurflConfig", "->", "capabilityFilter", ")", ";", "}" ]
Returns a WURFL device repository @param WURFL_Storage_Base $persistenceStorage @param WURFL_UserAgentHandlerChain $userAgentHandlerChain @return WURFL_CustomDeviceRepository Device repository @see WURFL_DeviceRepositoryBuilder::build()
[ "Returns", "a", "WURFL", "device", "repository" ]
0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2
https://github.com/acasademont/wurfl/blob/0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2/WURFL/WURFLManagerFactory.php#L173-L178
16,524
fuzz-productions/laravel-api-data
src/Schema/SchemaUtility.php
SchemaUtility.commentTable
public static function commentTable($table, $comment, $connection = null) { if (is_null($connection)) { $connection = DB::connection(); } if ($connection->getDriverName() === 'sqlite') { return; } $connection->statement( sprintf( 'ALTER TABLE `%s` COMMENT = "%s"', $table, addslashes($comment) ) ); }
php
public static function commentTable($table, $comment, $connection = null) { if (is_null($connection)) { $connection = DB::connection(); } if ($connection->getDriverName() === 'sqlite') { return; } $connection->statement( sprintf( 'ALTER TABLE `%s` COMMENT = "%s"', $table, addslashes($comment) ) ); }
[ "public", "static", "function", "commentTable", "(", "$", "table", ",", "$", "comment", ",", "$", "connection", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "connection", ")", ")", "{", "$", "connection", "=", "DB", "::", "connection", "(", ")", ";", "}", "if", "(", "$", "connection", "->", "getDriverName", "(", ")", "===", "'sqlite'", ")", "{", "return", ";", "}", "$", "connection", "->", "statement", "(", "sprintf", "(", "'ALTER TABLE `%s` COMMENT = \"%s\"'", ",", "$", "table", ",", "addslashes", "(", "$", "comment", ")", ")", ")", ";", "}" ]
Add a comment at the level of a table. @param string $table @param string $comment @param Connection $connection @return void
[ "Add", "a", "comment", "at", "the", "level", "of", "a", "table", "." ]
25e181860d2f269b3b212195944c2bca95b411bb
https://github.com/fuzz-productions/laravel-api-data/blob/25e181860d2f269b3b212195944c2bca95b411bb/src/Schema/SchemaUtility.php#L18-L33
16,525
fuzz-productions/laravel-api-data
src/Schema/SchemaUtility.php
SchemaUtility.describeTable
public static function describeTable($table, $connection = null) { if (is_null($connection)) { $connection = DB::connection(); } if ($connection->getDriverName() === 'sqlite') { $result = $connection->select(sprintf('PRAGMA table_info(%s)', $table)); $column_key = 'name'; } else { $result = $connection->select( sprintf( 'SELECT COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = \'%s\' and TABLE_SCHEMA = \'%s\'', $table, $connection->getDatabaseName() ) ); $column_key = 'COLUMN_NAME'; } return array_map( function ($item) use ($column_key) { return $item->$column_key; }, $result ); }
php
public static function describeTable($table, $connection = null) { if (is_null($connection)) { $connection = DB::connection(); } if ($connection->getDriverName() === 'sqlite') { $result = $connection->select(sprintf('PRAGMA table_info(%s)', $table)); $column_key = 'name'; } else { $result = $connection->select( sprintf( 'SELECT COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = \'%s\' and TABLE_SCHEMA = \'%s\'', $table, $connection->getDatabaseName() ) ); $column_key = 'COLUMN_NAME'; } return array_map( function ($item) use ($column_key) { return $item->$column_key; }, $result ); }
[ "public", "static", "function", "describeTable", "(", "$", "table", ",", "$", "connection", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "connection", ")", ")", "{", "$", "connection", "=", "DB", "::", "connection", "(", ")", ";", "}", "if", "(", "$", "connection", "->", "getDriverName", "(", ")", "===", "'sqlite'", ")", "{", "$", "result", "=", "$", "connection", "->", "select", "(", "sprintf", "(", "'PRAGMA table_info(%s)'", ",", "$", "table", ")", ")", ";", "$", "column_key", "=", "'name'", ";", "}", "else", "{", "$", "result", "=", "$", "connection", "->", "select", "(", "sprintf", "(", "'SELECT COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = \\'%s\\' and TABLE_SCHEMA = \\'%s\\''", ",", "$", "table", ",", "$", "connection", "->", "getDatabaseName", "(", ")", ")", ")", ";", "$", "column_key", "=", "'COLUMN_NAME'", ";", "}", "return", "array_map", "(", "function", "(", "$", "item", ")", "use", "(", "$", "column_key", ")", "{", "return", "$", "item", "->", "$", "column_key", ";", "}", ",", "$", "result", ")", ";", "}" ]
Describe a table's columns. @param string $table @param Connection $connection @return array
[ "Describe", "a", "table", "s", "columns", "." ]
25e181860d2f269b3b212195944c2bca95b411bb
https://github.com/fuzz-productions/laravel-api-data/blob/25e181860d2f269b3b212195944c2bca95b411bb/src/Schema/SchemaUtility.php#L42-L65
16,526
okvpn/fixture-bundle
src/Migration/Loader/DataFixturesLoader.php
DataFixturesLoader.isFixtureAlreadyLoaded
protected function isFixtureAlreadyLoaded($fixtureObject) { if (!$this->loadedFixtures) { $this->loadedFixtures = []; $loadedFixtures = $this->em->getRepository('OkvpnFixtureBundle:DataFixture')->findAll(); /** @var DataFixture $fixture */ foreach ($loadedFixtures as $fixture) { $this->loadedFixtures[$fixture->getClassName()] = $fixture->getVersion() ?: '0.0'; } } $alreadyLoaded = false; if (isset($this->loadedFixtures[get_class($fixtureObject)])) { $alreadyLoaded = true; $loadedVersion = $this->loadedFixtures[get_class($fixtureObject)]; if ($fixtureObject instanceof VersionedFixtureInterface && version_compare($loadedVersion, $fixtureObject->getVersion()) == -1 ) { if ($fixtureObject instanceof LoadedFixtureVersionAwareInterface) { $fixtureObject->setLoadedVersion($loadedVersion); } $alreadyLoaded = false; } } return $alreadyLoaded; }
php
protected function isFixtureAlreadyLoaded($fixtureObject) { if (!$this->loadedFixtures) { $this->loadedFixtures = []; $loadedFixtures = $this->em->getRepository('OkvpnFixtureBundle:DataFixture')->findAll(); /** @var DataFixture $fixture */ foreach ($loadedFixtures as $fixture) { $this->loadedFixtures[$fixture->getClassName()] = $fixture->getVersion() ?: '0.0'; } } $alreadyLoaded = false; if (isset($this->loadedFixtures[get_class($fixtureObject)])) { $alreadyLoaded = true; $loadedVersion = $this->loadedFixtures[get_class($fixtureObject)]; if ($fixtureObject instanceof VersionedFixtureInterface && version_compare($loadedVersion, $fixtureObject->getVersion()) == -1 ) { if ($fixtureObject instanceof LoadedFixtureVersionAwareInterface) { $fixtureObject->setLoadedVersion($loadedVersion); } $alreadyLoaded = false; } } return $alreadyLoaded; }
[ "protected", "function", "isFixtureAlreadyLoaded", "(", "$", "fixtureObject", ")", "{", "if", "(", "!", "$", "this", "->", "loadedFixtures", ")", "{", "$", "this", "->", "loadedFixtures", "=", "[", "]", ";", "$", "loadedFixtures", "=", "$", "this", "->", "em", "->", "getRepository", "(", "'OkvpnFixtureBundle:DataFixture'", ")", "->", "findAll", "(", ")", ";", "/** @var DataFixture $fixture */", "foreach", "(", "$", "loadedFixtures", "as", "$", "fixture", ")", "{", "$", "this", "->", "loadedFixtures", "[", "$", "fixture", "->", "getClassName", "(", ")", "]", "=", "$", "fixture", "->", "getVersion", "(", ")", "?", ":", "'0.0'", ";", "}", "}", "$", "alreadyLoaded", "=", "false", ";", "if", "(", "isset", "(", "$", "this", "->", "loadedFixtures", "[", "get_class", "(", "$", "fixtureObject", ")", "]", ")", ")", "{", "$", "alreadyLoaded", "=", "true", ";", "$", "loadedVersion", "=", "$", "this", "->", "loadedFixtures", "[", "get_class", "(", "$", "fixtureObject", ")", "]", ";", "if", "(", "$", "fixtureObject", "instanceof", "VersionedFixtureInterface", "&&", "version_compare", "(", "$", "loadedVersion", ",", "$", "fixtureObject", "->", "getVersion", "(", ")", ")", "==", "-", "1", ")", "{", "if", "(", "$", "fixtureObject", "instanceof", "LoadedFixtureVersionAwareInterface", ")", "{", "$", "fixtureObject", "->", "setLoadedVersion", "(", "$", "loadedVersion", ")", ";", "}", "$", "alreadyLoaded", "=", "false", ";", "}", "}", "return", "$", "alreadyLoaded", ";", "}" ]
Determines whether the given data fixture is already loaded or not @param object $fixtureObject @return bool
[ "Determines", "whether", "the", "given", "data", "fixture", "is", "already", "loaded", "or", "not" ]
243b5e4dff9773e97fa447280e929c936a5d66ae
https://github.com/okvpn/fixture-bundle/blob/243b5e4dff9773e97fa447280e929c936a5d66ae/src/Migration/Loader/DataFixturesLoader.php#L81-L109
16,527
WebDevTmas/date-repetition
src/DateRepetition/HourlyDateRepetition.php
HourlyDateRepetition.setMinute
public function setMinute($minute) { if(! in_array($minute, range(0, 59))) { throw new InvalidArgumentException('Minute must be between 0 and 59'); } $this->minute = $minute; return $this; }
php
public function setMinute($minute) { if(! in_array($minute, range(0, 59))) { throw new InvalidArgumentException('Minute must be between 0 and 59'); } $this->minute = $minute; return $this; }
[ "public", "function", "setMinute", "(", "$", "minute", ")", "{", "if", "(", "!", "in_array", "(", "$", "minute", ",", "range", "(", "0", ",", "59", ")", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Minute must be between 0 and 59'", ")", ";", "}", "$", "this", "->", "minute", "=", "$", "minute", ";", "return", "$", "this", ";", "}" ]
Sets minutes in repetition @param integer minutes @return this
[ "Sets", "minutes", "in", "repetition" ]
3ebd59f4ab3aab4b7497ebd767a57fad08277c6d
https://github.com/WebDevTmas/date-repetition/blob/3ebd59f4ab3aab4b7497ebd767a57fad08277c6d/src/DateRepetition/HourlyDateRepetition.php#L59-L66
16,528
Atlantic18/CoralCoreBundle
Service/Connector/AbstractConnector.php
AbstractConnector.doPostRequest
public function doPostRequest($uri, $data = null) { return $this->doRequest(Request::POST, $uri, $data); }
php
public function doPostRequest($uri, $data = null) { return $this->doRequest(Request::POST, $uri, $data); }
[ "public", "function", "doPostRequest", "(", "$", "uri", ",", "$", "data", "=", "null", ")", "{", "return", "$", "this", "->", "doRequest", "(", "Request", "::", "POST", ",", "$", "uri", ",", "$", "data", ")", ";", "}" ]
Create POST request to CORAL backend @param string $uri Service URI @param array $data Datat to be sent @return JsonResponse Response
[ "Create", "POST", "request", "to", "CORAL", "backend" ]
7d74ffaf51046ad13cbfc2b0b69d656a499f38ab
https://github.com/Atlantic18/CoralCoreBundle/blob/7d74ffaf51046ad13cbfc2b0b69d656a499f38ab/Service/Connector/AbstractConnector.php#L26-L29
16,529
etki/opencart-core-installer
src/FileJunglist.php
FileJunglist.saveModifiedFiles
public function saveModifiedFiles($installPath) { DebugPrinter::log('Saving modified items'); $tmpRoot = sys_get_temp_dir() . DIRECTORY_SEPARATOR; $installPath = trim($installPath, '\\/') . DIRECTORY_SEPARATOR; $fsm = new Filesystem; DebugPrinter::log( 'Items to search: %s', implode(', ', $this->modifiableFiles) ); foreach ($this->modifiableFiles as $file) { $source = $installPath . $file; $target = $tmpRoot . md5($source); if (!$fsm->exists($source)) { DebugPrinter::log('Item `%s` is missing, skipping it', $source); continue; } $args = array($source, $target,); DebugPrinter::log('Saving `%s` to `%s`', $args); if (is_dir($source)) { $fsm->mirror($source, $target); } else { $fsm->copy($source, $target); } } DebugPrinter::log('Finished saving modified items'); }
php
public function saveModifiedFiles($installPath) { DebugPrinter::log('Saving modified items'); $tmpRoot = sys_get_temp_dir() . DIRECTORY_SEPARATOR; $installPath = trim($installPath, '\\/') . DIRECTORY_SEPARATOR; $fsm = new Filesystem; DebugPrinter::log( 'Items to search: %s', implode(', ', $this->modifiableFiles) ); foreach ($this->modifiableFiles as $file) { $source = $installPath . $file; $target = $tmpRoot . md5($source); if (!$fsm->exists($source)) { DebugPrinter::log('Item `%s` is missing, skipping it', $source); continue; } $args = array($source, $target,); DebugPrinter::log('Saving `%s` to `%s`', $args); if (is_dir($source)) { $fsm->mirror($source, $target); } else { $fsm->copy($source, $target); } } DebugPrinter::log('Finished saving modified items'); }
[ "public", "function", "saveModifiedFiles", "(", "$", "installPath", ")", "{", "DebugPrinter", "::", "log", "(", "'Saving modified items'", ")", ";", "$", "tmpRoot", "=", "sys_get_temp_dir", "(", ")", ".", "DIRECTORY_SEPARATOR", ";", "$", "installPath", "=", "trim", "(", "$", "installPath", ",", "'\\\\/'", ")", ".", "DIRECTORY_SEPARATOR", ";", "$", "fsm", "=", "new", "Filesystem", ";", "DebugPrinter", "::", "log", "(", "'Items to search: %s'", ",", "implode", "(", "', '", ",", "$", "this", "->", "modifiableFiles", ")", ")", ";", "foreach", "(", "$", "this", "->", "modifiableFiles", "as", "$", "file", ")", "{", "$", "source", "=", "$", "installPath", ".", "$", "file", ";", "$", "target", "=", "$", "tmpRoot", ".", "md5", "(", "$", "source", ")", ";", "if", "(", "!", "$", "fsm", "->", "exists", "(", "$", "source", ")", ")", "{", "DebugPrinter", "::", "log", "(", "'Item `%s` is missing, skipping it'", ",", "$", "source", ")", ";", "continue", ";", "}", "$", "args", "=", "array", "(", "$", "source", ",", "$", "target", ",", ")", ";", "DebugPrinter", "::", "log", "(", "'Saving `%s` to `%s`'", ",", "$", "args", ")", ";", "if", "(", "is_dir", "(", "$", "source", ")", ")", "{", "$", "fsm", "->", "mirror", "(", "$", "source", ",", "$", "target", ")", ";", "}", "else", "{", "$", "fsm", "->", "copy", "(", "$", "source", ",", "$", "target", ")", ";", "}", "}", "DebugPrinter", "::", "log", "(", "'Finished saving modified items'", ")", ";", "}" ]
Saves config files during install. @param string $installPath Opencart install path. @return void @since 0.1.0
[ "Saves", "config", "files", "during", "install", "." ]
e651c94982afe966cd36977bbdc2ff4f7e785475
https://github.com/etki/opencart-core-installer/blob/e651c94982afe966cd36977bbdc2ff4f7e785475/src/FileJunglist.php#L58-L84
16,530
etki/opencart-core-installer
src/FileJunglist.php
FileJunglist.restoreModifiedFiles
public function restoreModifiedFiles($installPath) { DebugPrinter::log('Restoring modified items'); $tmpRoot = sys_get_temp_dir() . DIRECTORY_SEPARATOR; $installPath = trim($installPath, '\\/') . DIRECTORY_SEPARATOR; $fsm = new Filesystem; DebugPrinter::log( 'Items to search: %s', implode(', ', $this->modifiableFiles) ); foreach ($this->modifiableFiles as $file) { $target = $installPath . $file; $source = $tmpRoot . md5($target); if (!$fsm->exists($source)) { DebugPrinter::log('Item `%s` is missing, skipping it', $source); continue; } $args = array($source, $target,); DebugPrinter::log('Restoring `%s` to `%s`', $args); if ($fsm->exists($target)) { $fsm->remove($target); } $fsm->rename($source, $target, true); } DebugPrinter::log('Finished restoring modified items'); }
php
public function restoreModifiedFiles($installPath) { DebugPrinter::log('Restoring modified items'); $tmpRoot = sys_get_temp_dir() . DIRECTORY_SEPARATOR; $installPath = trim($installPath, '\\/') . DIRECTORY_SEPARATOR; $fsm = new Filesystem; DebugPrinter::log( 'Items to search: %s', implode(', ', $this->modifiableFiles) ); foreach ($this->modifiableFiles as $file) { $target = $installPath . $file; $source = $tmpRoot . md5($target); if (!$fsm->exists($source)) { DebugPrinter::log('Item `%s` is missing, skipping it', $source); continue; } $args = array($source, $target,); DebugPrinter::log('Restoring `%s` to `%s`', $args); if ($fsm->exists($target)) { $fsm->remove($target); } $fsm->rename($source, $target, true); } DebugPrinter::log('Finished restoring modified items'); }
[ "public", "function", "restoreModifiedFiles", "(", "$", "installPath", ")", "{", "DebugPrinter", "::", "log", "(", "'Restoring modified items'", ")", ";", "$", "tmpRoot", "=", "sys_get_temp_dir", "(", ")", ".", "DIRECTORY_SEPARATOR", ";", "$", "installPath", "=", "trim", "(", "$", "installPath", ",", "'\\\\/'", ")", ".", "DIRECTORY_SEPARATOR", ";", "$", "fsm", "=", "new", "Filesystem", ";", "DebugPrinter", "::", "log", "(", "'Items to search: %s'", ",", "implode", "(", "', '", ",", "$", "this", "->", "modifiableFiles", ")", ")", ";", "foreach", "(", "$", "this", "->", "modifiableFiles", "as", "$", "file", ")", "{", "$", "target", "=", "$", "installPath", ".", "$", "file", ";", "$", "source", "=", "$", "tmpRoot", ".", "md5", "(", "$", "target", ")", ";", "if", "(", "!", "$", "fsm", "->", "exists", "(", "$", "source", ")", ")", "{", "DebugPrinter", "::", "log", "(", "'Item `%s` is missing, skipping it'", ",", "$", "source", ")", ";", "continue", ";", "}", "$", "args", "=", "array", "(", "$", "source", ",", "$", "target", ",", ")", ";", "DebugPrinter", "::", "log", "(", "'Restoring `%s` to `%s`'", ",", "$", "args", ")", ";", "if", "(", "$", "fsm", "->", "exists", "(", "$", "target", ")", ")", "{", "$", "fsm", "->", "remove", "(", "$", "target", ")", ";", "}", "$", "fsm", "->", "rename", "(", "$", "source", ",", "$", "target", ",", "true", ")", ";", "}", "DebugPrinter", "::", "log", "(", "'Finished restoring modified items'", ")", ";", "}" ]
Restores previously saved config files. @param string $installPath Opencart installation path. @return void @since 0.1.1
[ "Restores", "previously", "saved", "config", "files", "." ]
e651c94982afe966cd36977bbdc2ff4f7e785475
https://github.com/etki/opencart-core-installer/blob/e651c94982afe966cd36977bbdc2ff4f7e785475/src/FileJunglist.php#L94-L119
16,531
etki/opencart-core-installer
src/FileJunglist.php
FileJunglist.setPermissions
protected function setPermissions($installPath, $basePerms = 0644) { $fsm = new Filesystem; foreach ($this->chmodNodes as $fsNode) { $path = $installPath . DIRECTORY_SEPARATOR . $fsNode; $isFile = is_file($path); $isDir = is_dir($path); if (!$isFile && !$isDir) { DebugPrinter::log('Filesystem node %s not found', $path); continue; } $perms = $basePerms; if ($isDir) { $perms |= 0111; } $args = array($path, decoct($perms),); DebugPrinter::log('Chmodding `%s` to `%s`', $args); $fsm->chmod($path, $perms); } }
php
protected function setPermissions($installPath, $basePerms = 0644) { $fsm = new Filesystem; foreach ($this->chmodNodes as $fsNode) { $path = $installPath . DIRECTORY_SEPARATOR . $fsNode; $isFile = is_file($path); $isDir = is_dir($path); if (!$isFile && !$isDir) { DebugPrinter::log('Filesystem node %s not found', $path); continue; } $perms = $basePerms; if ($isDir) { $perms |= 0111; } $args = array($path, decoct($perms),); DebugPrinter::log('Chmodding `%s` to `%s`', $args); $fsm->chmod($path, $perms); } }
[ "protected", "function", "setPermissions", "(", "$", "installPath", ",", "$", "basePerms", "=", "0644", ")", "{", "$", "fsm", "=", "new", "Filesystem", ";", "foreach", "(", "$", "this", "->", "chmodNodes", "as", "$", "fsNode", ")", "{", "$", "path", "=", "$", "installPath", ".", "DIRECTORY_SEPARATOR", ".", "$", "fsNode", ";", "$", "isFile", "=", "is_file", "(", "$", "path", ")", ";", "$", "isDir", "=", "is_dir", "(", "$", "path", ")", ";", "if", "(", "!", "$", "isFile", "&&", "!", "$", "isDir", ")", "{", "DebugPrinter", "::", "log", "(", "'Filesystem node %s not found'", ",", "$", "path", ")", ";", "continue", ";", "}", "$", "perms", "=", "$", "basePerms", ";", "if", "(", "$", "isDir", ")", "{", "$", "perms", "|=", "0111", ";", "}", "$", "args", "=", "array", "(", "$", "path", ",", "decoct", "(", "$", "perms", ")", ",", ")", ";", "DebugPrinter", "::", "log", "(", "'Chmodding `%s` to `%s`'", ",", "$", "args", ")", ";", "$", "fsm", "->", "chmod", "(", "$", "path", ",", "$", "perms", ")", ";", "}", "}" ]
Sets Opencart folder permissions as required in manual. @param string $installPath Opencart install path. @param int $basePerms Base permissions. Please note that all directories permissions will be masked by 111 (this will set all three ugo executive bits). @return void @since 0.1.1
[ "Sets", "Opencart", "folder", "permissions", "as", "required", "in", "manual", "." ]
e651c94982afe966cd36977bbdc2ff4f7e785475
https://github.com/etki/opencart-core-installer/blob/e651c94982afe966cd36977bbdc2ff4f7e785475/src/FileJunglist.php#L132-L151
16,532
etki/opencart-core-installer
src/FileJunglist.php
FileJunglist.rotateInstalledFiles
public function rotateInstalledFiles($installPath) { $fsm = new Filesystem; $tempDir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid('oci-'); DebugPrinter::log('Rotating files using `%s` dir', $tempDir); // unzipped contents may or may not contain `upload.*` directory, // which holds actual opencart contents. $dirs = glob($installPath . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR); foreach ($dirs as $key => $dir) { if ($dir[0] === '.') { unset($dirs[$key]); } } if (sizeof($dirs) === 1) { $subDirectory = $tempDir . DIRECTORY_SEPARATOR . dirname(reset($dirs)); $fsm->rename($installPath, $tempDir); $fsm->rename($subDirectory, $installPath); $fsm->remove($tempDir); } }
php
public function rotateInstalledFiles($installPath) { $fsm = new Filesystem; $tempDir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid('oci-'); DebugPrinter::log('Rotating files using `%s` dir', $tempDir); // unzipped contents may or may not contain `upload.*` directory, // which holds actual opencart contents. $dirs = glob($installPath . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR); foreach ($dirs as $key => $dir) { if ($dir[0] === '.') { unset($dirs[$key]); } } if (sizeof($dirs) === 1) { $subDirectory = $tempDir . DIRECTORY_SEPARATOR . dirname(reset($dirs)); $fsm->rename($installPath, $tempDir); $fsm->rename($subDirectory, $installPath); $fsm->remove($tempDir); } }
[ "public", "function", "rotateInstalledFiles", "(", "$", "installPath", ")", "{", "$", "fsm", "=", "new", "Filesystem", ";", "$", "tempDir", "=", "sys_get_temp_dir", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "uniqid", "(", "'oci-'", ")", ";", "DebugPrinter", "::", "log", "(", "'Rotating files using `%s` dir'", ",", "$", "tempDir", ")", ";", "// unzipped contents may or may not contain `upload.*` directory,", "// which holds actual opencart contents.", "$", "dirs", "=", "glob", "(", "$", "installPath", ".", "DIRECTORY_SEPARATOR", ".", "'*'", ",", "GLOB_ONLYDIR", ")", ";", "foreach", "(", "$", "dirs", "as", "$", "key", "=>", "$", "dir", ")", "{", "if", "(", "$", "dir", "[", "0", "]", "===", "'.'", ")", "{", "unset", "(", "$", "dirs", "[", "$", "key", "]", ")", ";", "}", "}", "if", "(", "sizeof", "(", "$", "dirs", ")", "===", "1", ")", "{", "$", "subDirectory", "=", "$", "tempDir", ".", "DIRECTORY_SEPARATOR", ".", "dirname", "(", "reset", "(", "$", "dirs", ")", ")", ";", "$", "fsm", "->", "rename", "(", "$", "installPath", ",", "$", "tempDir", ")", ";", "$", "fsm", "->", "rename", "(", "$", "subDirectory", ",", "$", "installPath", ")", ";", "$", "fsm", "->", "remove", "(", "$", "tempDir", ")", ";", "}", "}" ]
Moves installed files out of `upload` dir. @param string $installPath Opencart installation path. @return void @since 0.1.0
[ "Moves", "installed", "files", "out", "of", "upload", "dir", "." ]
e651c94982afe966cd36977bbdc2ff4f7e785475
https://github.com/etki/opencart-core-installer/blob/e651c94982afe966cd36977bbdc2ff4f7e785475/src/FileJunglist.php#L161-L181
16,533
etki/opencart-core-installer
src/FileJunglist.php
FileJunglist.copyConfigFiles
public function copyConfigFiles($installPath) { $filesystem = new Filesystem; $configFiles = array('/config', '/admin/config',); foreach ($configFiles as $configFile) { $source = $installPath . $configFile . '-dist.php'; $target = $installPath . $configFile . '.php'; if ($filesystem->exists($source)) { $filesystem->copy($source, $target); } else { DebugPrinter::log( 'File `%s` doesn\'t exist, though i am sure it should', $source ); } } }
php
public function copyConfigFiles($installPath) { $filesystem = new Filesystem; $configFiles = array('/config', '/admin/config',); foreach ($configFiles as $configFile) { $source = $installPath . $configFile . '-dist.php'; $target = $installPath . $configFile . '.php'; if ($filesystem->exists($source)) { $filesystem->copy($source, $target); } else { DebugPrinter::log( 'File `%s` doesn\'t exist, though i am sure it should', $source ); } } }
[ "public", "function", "copyConfigFiles", "(", "$", "installPath", ")", "{", "$", "filesystem", "=", "new", "Filesystem", ";", "$", "configFiles", "=", "array", "(", "'/config'", ",", "'/admin/config'", ",", ")", ";", "foreach", "(", "$", "configFiles", "as", "$", "configFile", ")", "{", "$", "source", "=", "$", "installPath", ".", "$", "configFile", ".", "'-dist.php'", ";", "$", "target", "=", "$", "installPath", ".", "$", "configFile", ".", "'.php'", ";", "if", "(", "$", "filesystem", "->", "exists", "(", "$", "source", ")", ")", "{", "$", "filesystem", "->", "copy", "(", "$", "source", ",", "$", "target", ")", ";", "}", "else", "{", "DebugPrinter", "::", "log", "(", "'File `%s` doesn\\'t exist, though i am sure it should'", ",", "$", "source", ")", ";", "}", "}", "}" ]
Copies configuration files from their dists as specified by installation notes. @param string $installPath Opencart installation path. @return void @since 0.1.0
[ "Copies", "configuration", "files", "from", "their", "dists", "as", "specified", "by", "installation", "notes", "." ]
e651c94982afe966cd36977bbdc2ff4f7e785475
https://github.com/etki/opencart-core-installer/blob/e651c94982afe966cd36977bbdc2ff4f7e785475/src/FileJunglist.php#L192-L208
16,534
pipelinersales/pipeliner-php-sdk
src/PipelinerSales/ApiClient/Http/Response.php
Response.decodeJson
public function decodeJson($assoc = false) { $result = json_decode($this->body, $assoc); if (json_last_error() !== JSON_ERROR_NONE) { throw new PipelinerHttpException($this, "Error while parsing returned JSON"); } return $result; }
php
public function decodeJson($assoc = false) { $result = json_decode($this->body, $assoc); if (json_last_error() !== JSON_ERROR_NONE) { throw new PipelinerHttpException($this, "Error while parsing returned JSON"); } return $result; }
[ "public", "function", "decodeJson", "(", "$", "assoc", "=", "false", ")", "{", "$", "result", "=", "json_decode", "(", "$", "this", "->", "body", ",", "$", "assoc", ")", ";", "if", "(", "json_last_error", "(", ")", "!==", "JSON_ERROR_NONE", ")", "{", "throw", "new", "PipelinerHttpException", "(", "$", "this", ",", "\"Error while parsing returned JSON\"", ")", ";", "}", "return", "$", "result", ";", "}" ]
Decodes the response's body into an object. @param boolean $assoc when true, returned objects will be converted into associative arrays. @return \stdClass|array @throws PipelinerHttpException on error while decoding the json string
[ "Decodes", "the", "response", "s", "body", "into", "an", "object", "." ]
a020149ffde815be17634542010814cf854c3d5f
https://github.com/pipelinersales/pipeliner-php-sdk/blob/a020149ffde815be17634542010814cf854c3d5f/src/PipelinerSales/ApiClient/Http/Response.php#L70-L79
16,535
czim/laravel-pxlcms
src/Generator/ModelWriter.php
ModelWriter.appendRelatedModelsToModelData
protected function appendRelatedModelsToModelData(array $model) { $relationships = array_merge( array_get($model, 'relationships.normal'), array_get($model, 'relationships.reverse') ); $model['related_models'] = []; foreach ($relationships as $name => $relationship) { $relatedModelId = $relationship['model']; if (isset($model['related_models'][ $relatedModelId ])) continue; $model['related_models'][ $relatedModelId ] = $this->data['models'][ $relatedModelId ]; } return $model; }
php
protected function appendRelatedModelsToModelData(array $model) { $relationships = array_merge( array_get($model, 'relationships.normal'), array_get($model, 'relationships.reverse') ); $model['related_models'] = []; foreach ($relationships as $name => $relationship) { $relatedModelId = $relationship['model']; if (isset($model['related_models'][ $relatedModelId ])) continue; $model['related_models'][ $relatedModelId ] = $this->data['models'][ $relatedModelId ]; } return $model; }
[ "protected", "function", "appendRelatedModelsToModelData", "(", "array", "$", "model", ")", "{", "$", "relationships", "=", "array_merge", "(", "array_get", "(", "$", "model", ",", "'relationships.normal'", ")", ",", "array_get", "(", "$", "model", ",", "'relationships.reverse'", ")", ")", ";", "$", "model", "[", "'related_models'", "]", "=", "[", "]", ";", "foreach", "(", "$", "relationships", "as", "$", "name", "=>", "$", "relationship", ")", "{", "$", "relatedModelId", "=", "$", "relationship", "[", "'model'", "]", ";", "if", "(", "isset", "(", "$", "model", "[", "'related_models'", "]", "[", "$", "relatedModelId", "]", ")", ")", "continue", ";", "$", "model", "[", "'related_models'", "]", "[", "$", "relatedModelId", "]", "=", "$", "this", "->", "data", "[", "'models'", "]", "[", "$", "relatedModelId", "]", ";", "}", "return", "$", "model", ";", "}" ]
Append 'related' model data for related models @param array $model @return array
[ "Append", "related", "model", "data", "for", "related", "models" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/ModelWriter.php#L145-L164
16,536
czim/laravel-pxlcms
src/Generator/ModelWriter.php
ModelWriter.makeTranslatedDataFromModelData
protected function makeTranslatedDataFromModelData(array $model) { // translated model is sluggable if model is, but on translated property or column $sluggable = ($model['sluggable'] && array_get($model, 'sluggable_setup.translated')); return [ 'module' => $model['module'], 'name' => $model['name'] . config('pxlcms.generator.models.translation_model_postfix'), 'table' => ! empty($model['table']) ? $model['table'] . snake_case(config('pxlcms.tables.translation_postfix', '_ml')) : null, 'cached' => $model['cached'], 'is_translated' => false, 'is_translation' => true, // only true if it is a Translation model itself 'is_listified' => false, 'order_by' => [], // attributes 'normal_fillable' => $model['translated_attributes'], 'translated_fillable' => [], 'hidden' => [], 'casts' => [], 'dates' => [], 'defaults' => [], 'normal_attributes' => [], 'translated_attributes' => [], 'timestamps' => null, // categories 'categories_module' => null, // relations 'relations_config' => [], 'relationships' => [ 'normal' => [], 'reverse' => [], 'image' => [], 'file' => [], 'checkbox' => [], ], // special 'sluggable' => $sluggable, 'sluggable_setup' => $sluggable ? $model['sluggable_setup'] : [], 'scope_active' => false, 'scope_position' => false, ]; }
php
protected function makeTranslatedDataFromModelData(array $model) { // translated model is sluggable if model is, but on translated property or column $sluggable = ($model['sluggable'] && array_get($model, 'sluggable_setup.translated')); return [ 'module' => $model['module'], 'name' => $model['name'] . config('pxlcms.generator.models.translation_model_postfix'), 'table' => ! empty($model['table']) ? $model['table'] . snake_case(config('pxlcms.tables.translation_postfix', '_ml')) : null, 'cached' => $model['cached'], 'is_translated' => false, 'is_translation' => true, // only true if it is a Translation model itself 'is_listified' => false, 'order_by' => [], // attributes 'normal_fillable' => $model['translated_attributes'], 'translated_fillable' => [], 'hidden' => [], 'casts' => [], 'dates' => [], 'defaults' => [], 'normal_attributes' => [], 'translated_attributes' => [], 'timestamps' => null, // categories 'categories_module' => null, // relations 'relations_config' => [], 'relationships' => [ 'normal' => [], 'reverse' => [], 'image' => [], 'file' => [], 'checkbox' => [], ], // special 'sluggable' => $sluggable, 'sluggable_setup' => $sluggable ? $model['sluggable_setup'] : [], 'scope_active' => false, 'scope_position' => false, ]; }
[ "protected", "function", "makeTranslatedDataFromModelData", "(", "array", "$", "model", ")", "{", "// translated model is sluggable if model is, but on translated property or column", "$", "sluggable", "=", "(", "$", "model", "[", "'sluggable'", "]", "&&", "array_get", "(", "$", "model", ",", "'sluggable_setup.translated'", ")", ")", ";", "return", "[", "'module'", "=>", "$", "model", "[", "'module'", "]", ",", "'name'", "=>", "$", "model", "[", "'name'", "]", ".", "config", "(", "'pxlcms.generator.models.translation_model_postfix'", ")", ",", "'table'", "=>", "!", "empty", "(", "$", "model", "[", "'table'", "]", ")", "?", "$", "model", "[", "'table'", "]", ".", "snake_case", "(", "config", "(", "'pxlcms.tables.translation_postfix'", ",", "'_ml'", ")", ")", ":", "null", ",", "'cached'", "=>", "$", "model", "[", "'cached'", "]", ",", "'is_translated'", "=>", "false", ",", "'is_translation'", "=>", "true", ",", "// only true if it is a Translation model itself", "'is_listified'", "=>", "false", ",", "'order_by'", "=>", "[", "]", ",", "// attributes", "'normal_fillable'", "=>", "$", "model", "[", "'translated_attributes'", "]", ",", "'translated_fillable'", "=>", "[", "]", ",", "'hidden'", "=>", "[", "]", ",", "'casts'", "=>", "[", "]", ",", "'dates'", "=>", "[", "]", ",", "'defaults'", "=>", "[", "]", ",", "'normal_attributes'", "=>", "[", "]", ",", "'translated_attributes'", "=>", "[", "]", ",", "'timestamps'", "=>", "null", ",", "// categories", "'categories_module'", "=>", "null", ",", "// relations", "'relations_config'", "=>", "[", "]", ",", "'relationships'", "=>", "[", "'normal'", "=>", "[", "]", ",", "'reverse'", "=>", "[", "]", ",", "'image'", "=>", "[", "]", ",", "'file'", "=>", "[", "]", ",", "'checkbox'", "=>", "[", "]", ",", "]", ",", "// special", "'sluggable'", "=>", "$", "sluggable", ",", "'sluggable_setup'", "=>", "$", "sluggable", "?", "$", "model", "[", "'sluggable_setup'", "]", ":", "[", "]", ",", "'scope_active'", "=>", "false", ",", "'scope_position'", "=>", "false", ",", "]", ";", "}" ]
Make model data array for translation model @param array $model @return array
[ "Make", "model", "data", "array", "for", "translation", "model" ]
910297d2a3f2db86dde51b0e10fe5aad45f1aa1a
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/ModelWriter.php#L173-L216
16,537
vcn/enum
src/Enum/Matcher.php
Matcher.get
public function get() { return array_key_exists($this->subject->getName(), $this->matches) ? $this->matches[$this->subject->getName()]->get() : $this->surrogate->get(); }
php
public function get() { return array_key_exists($this->subject->getName(), $this->matches) ? $this->matches[$this->subject->getName()]->get() : $this->surrogate->get(); }
[ "public", "function", "get", "(", ")", "{", "return", "array_key_exists", "(", "$", "this", "->", "subject", "->", "getName", "(", ")", ",", "$", "this", "->", "matches", ")", "?", "$", "this", "->", "matches", "[", "$", "this", "->", "subject", "->", "getName", "(", ")", "]", "->", "get", "(", ")", ":", "$", "this", "->", "surrogate", "->", "get", "(", ")", ";", "}" ]
Provides the value the instance of the mapped subject is mapped to, or throws a runtime exception if the instance has not been mapped to anything. <br/> For example: <br/> ``` $fruit ->when(Fruit::BANANA(), 'banana') ->when(Fruit::APPLE(), 'apple') ->get(); ``` <br/> will yield: <br/> `'banana'` if `$fruit = Fruit::BANANA()` or <br/> `'apple'` if `$fruit = Fruit::APPLE()` or <br/> a thrown exception if `$fruit = Fruit::EGGPLANT()` @return mixed @throws Enum\Matcher\Exception\MatchExhausted
[ "Provides", "the", "value", "the", "instance", "of", "the", "mapped", "subject", "is", "mapped", "to", "or", "throws", "a", "runtime", "exception", "if", "the", "instance", "has", "not", "been", "mapped", "to", "anything", "." ]
ced38687b6140858956778140915d5d5a6397f23
https://github.com/vcn/enum/blob/ced38687b6140858956778140915d5d5a6397f23/src/Enum/Matcher.php#L350-L355
16,538
withfatpanda/illuminate-wordpress
src/WordPress/Models/ProfileSection.php
ProfileSection.factory
static function factory(Plugin $plugin, $type) { $plugin->validator->extend('can_edit', function($attribute, $value, $parameters, $validator) { if (empty($value)) { return false; } $current_user = wp_get_current_user(); if (empty($current_user)) { return false; } if ($attribute === 'user_id') { $target_user = get_user_by('ID', $value); } else { $target_user = get_user_by($attribute, $value); } if ($current_user->ID === $target_user->ID) { return true; } else if ($current_user->can('administrator')) { return true; } else { return false; } }); if (empty($type)) { throw new \Exception("Missing required argument: type"); } $type = urldecode($type); if (class_exists($type)) { $implements = class_implements($type); if (!isset($implements['FatPanda\Illuminate\WordPress\Concerns\ProfileSectionContract'])) { throw new \Exception("Profile Section type {$type} does not implement ProfileSectionContract"); } $section = new $type(); $section->setPlugin($plugin); return $section; } else { return new SimpleProfileSection($type); } }
php
static function factory(Plugin $plugin, $type) { $plugin->validator->extend('can_edit', function($attribute, $value, $parameters, $validator) { if (empty($value)) { return false; } $current_user = wp_get_current_user(); if (empty($current_user)) { return false; } if ($attribute === 'user_id') { $target_user = get_user_by('ID', $value); } else { $target_user = get_user_by($attribute, $value); } if ($current_user->ID === $target_user->ID) { return true; } else if ($current_user->can('administrator')) { return true; } else { return false; } }); if (empty($type)) { throw new \Exception("Missing required argument: type"); } $type = urldecode($type); if (class_exists($type)) { $implements = class_implements($type); if (!isset($implements['FatPanda\Illuminate\WordPress\Concerns\ProfileSectionContract'])) { throw new \Exception("Profile Section type {$type} does not implement ProfileSectionContract"); } $section = new $type(); $section->setPlugin($plugin); return $section; } else { return new SimpleProfileSection($type); } }
[ "static", "function", "factory", "(", "Plugin", "$", "plugin", ",", "$", "type", ")", "{", "$", "plugin", "->", "validator", "->", "extend", "(", "'can_edit'", ",", "function", "(", "$", "attribute", ",", "$", "value", ",", "$", "parameters", ",", "$", "validator", ")", "{", "if", "(", "empty", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "$", "current_user", "=", "wp_get_current_user", "(", ")", ";", "if", "(", "empty", "(", "$", "current_user", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "attribute", "===", "'user_id'", ")", "{", "$", "target_user", "=", "get_user_by", "(", "'ID'", ",", "$", "value", ")", ";", "}", "else", "{", "$", "target_user", "=", "get_user_by", "(", "$", "attribute", ",", "$", "value", ")", ";", "}", "if", "(", "$", "current_user", "->", "ID", "===", "$", "target_user", "->", "ID", ")", "{", "return", "true", ";", "}", "else", "if", "(", "$", "current_user", "->", "can", "(", "'administrator'", ")", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}", ")", ";", "if", "(", "empty", "(", "$", "type", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Missing required argument: type\"", ")", ";", "}", "$", "type", "=", "urldecode", "(", "$", "type", ")", ";", "if", "(", "class_exists", "(", "$", "type", ")", ")", "{", "$", "implements", "=", "class_implements", "(", "$", "type", ")", ";", "if", "(", "!", "isset", "(", "$", "implements", "[", "'FatPanda\\Illuminate\\WordPress\\Concerns\\ProfileSectionContract'", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Profile Section type {$type} does not implement ProfileSectionContract\"", ")", ";", "}", "$", "section", "=", "new", "$", "type", "(", ")", ";", "$", "section", "->", "setPlugin", "(", "$", "plugin", ")", ";", "return", "$", "section", ";", "}", "else", "{", "return", "new", "SimpleProfileSection", "(", "$", "type", ")", ";", "}", "}" ]
Create a profile section of the given type, and associate it with the given Plugin @param Plugin @param String A classname of some class that implements ProfileSectionContract @return PluginSectionContract implementation @throws Exception If given class does not implement ProfileSectionContract
[ "Create", "a", "profile", "section", "of", "the", "given", "type", "and", "associate", "it", "with", "the", "given", "Plugin" ]
b426ca81a55367459430c974932ee5a941d759d8
https://github.com/withfatpanda/illuminate-wordpress/blob/b426ca81a55367459430c974932ee5a941d759d8/src/WordPress/Models/ProfileSection.php#L23-L69
16,539
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/PermissionQuery.php
PermissionQuery.usePermissionRelatedByParentIdQuery
public function usePermissionRelatedByParentIdQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinPermissionRelatedByParentId($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'PermissionRelatedByParentId', '\Alchemy\Component\Cerberus\Model\PermissionQuery'); }
php
public function usePermissionRelatedByParentIdQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinPermissionRelatedByParentId($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'PermissionRelatedByParentId', '\Alchemy\Component\Cerberus\Model\PermissionQuery'); }
[ "public", "function", "usePermissionRelatedByParentIdQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "Criteria", "::", "LEFT_JOIN", ")", "{", "return", "$", "this", "->", "joinPermissionRelatedByParentId", "(", "$", "relationAlias", ",", "$", "joinType", ")", "->", "useQuery", "(", "$", "relationAlias", "?", "$", "relationAlias", ":", "'PermissionRelatedByParentId'", ",", "'\\Alchemy\\Component\\Cerberus\\Model\\PermissionQuery'", ")", ";", "}" ]
Use the PermissionRelatedByParentId relation Permission object @see useQuery() @param string $relationAlias optional alias for the relation, to be used as main alias in the secondary query @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' @return \Alchemy\Component\Cerberus\Model\PermissionQuery A secondary query class using the current class as primary query
[ "Use", "the", "PermissionRelatedByParentId", "relation", "Permission", "object" ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/PermissionQuery.php#L580-L585
16,540
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/PermissionQuery.php
PermissionQuery.usePermissionRelatedByIdQuery
public function usePermissionRelatedByIdQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinPermissionRelatedById($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'PermissionRelatedById', '\Alchemy\Component\Cerberus\Model\PermissionQuery'); }
php
public function usePermissionRelatedByIdQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinPermissionRelatedById($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'PermissionRelatedById', '\Alchemy\Component\Cerberus\Model\PermissionQuery'); }
[ "public", "function", "usePermissionRelatedByIdQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "Criteria", "::", "LEFT_JOIN", ")", "{", "return", "$", "this", "->", "joinPermissionRelatedById", "(", "$", "relationAlias", ",", "$", "joinType", ")", "->", "useQuery", "(", "$", "relationAlias", "?", "$", "relationAlias", ":", "'PermissionRelatedById'", ",", "'\\Alchemy\\Component\\Cerberus\\Model\\PermissionQuery'", ")", ";", "}" ]
Use the PermissionRelatedById relation Permission object @see useQuery() @param string $relationAlias optional alias for the relation, to be used as main alias in the secondary query @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' @return \Alchemy\Component\Cerberus\Model\PermissionQuery A secondary query class using the current class as primary query
[ "Use", "the", "PermissionRelatedById", "relation", "Permission", "object" ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/PermissionQuery.php#L653-L658
16,541
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/PermissionQuery.php
PermissionQuery.filterByRolePermission
public function filterByRolePermission($rolePermission, $comparison = null) { if ($rolePermission instanceof \Alchemy\Component\Cerberus\Model\RolePermission) { return $this ->addUsingAlias(PermissionTableMap::COL_ID, $rolePermission->getPermissionId(), $comparison); } elseif ($rolePermission instanceof ObjectCollection) { return $this ->useRolePermissionQuery() ->filterByPrimaryKeys($rolePermission->getPrimaryKeys()) ->endUse(); } else { throw new PropelException('filterByRolePermission() only accepts arguments of type \Alchemy\Component\Cerberus\Model\RolePermission or Collection'); } }
php
public function filterByRolePermission($rolePermission, $comparison = null) { if ($rolePermission instanceof \Alchemy\Component\Cerberus\Model\RolePermission) { return $this ->addUsingAlias(PermissionTableMap::COL_ID, $rolePermission->getPermissionId(), $comparison); } elseif ($rolePermission instanceof ObjectCollection) { return $this ->useRolePermissionQuery() ->filterByPrimaryKeys($rolePermission->getPrimaryKeys()) ->endUse(); } else { throw new PropelException('filterByRolePermission() only accepts arguments of type \Alchemy\Component\Cerberus\Model\RolePermission or Collection'); } }
[ "public", "function", "filterByRolePermission", "(", "$", "rolePermission", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "$", "rolePermission", "instanceof", "\\", "Alchemy", "\\", "Component", "\\", "Cerberus", "\\", "Model", "\\", "RolePermission", ")", "{", "return", "$", "this", "->", "addUsingAlias", "(", "PermissionTableMap", "::", "COL_ID", ",", "$", "rolePermission", "->", "getPermissionId", "(", ")", ",", "$", "comparison", ")", ";", "}", "elseif", "(", "$", "rolePermission", "instanceof", "ObjectCollection", ")", "{", "return", "$", "this", "->", "useRolePermissionQuery", "(", ")", "->", "filterByPrimaryKeys", "(", "$", "rolePermission", "->", "getPrimaryKeys", "(", ")", ")", "->", "endUse", "(", ")", ";", "}", "else", "{", "throw", "new", "PropelException", "(", "'filterByRolePermission() only accepts arguments of type \\Alchemy\\Component\\Cerberus\\Model\\RolePermission or Collection'", ")", ";", "}", "}" ]
Filter the query by a related \Alchemy\Component\Cerberus\Model\RolePermission object @param \Alchemy\Component\Cerberus\Model\RolePermission|ObjectCollection $rolePermission the related object to use as filter @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildPermissionQuery The current query, for fluid interface
[ "Filter", "the", "query", "by", "a", "related", "\\", "Alchemy", "\\", "Component", "\\", "Cerberus", "\\", "Model", "\\", "RolePermission", "object" ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/PermissionQuery.php#L668-L681
16,542
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/PermissionQuery.php
PermissionQuery.filterByRole
public function filterByRole($role, $comparison = Criteria::EQUAL) { return $this ->useRolePermissionQuery() ->filterByRole($role, $comparison) ->endUse(); }
php
public function filterByRole($role, $comparison = Criteria::EQUAL) { return $this ->useRolePermissionQuery() ->filterByRole($role, $comparison) ->endUse(); }
[ "public", "function", "filterByRole", "(", "$", "role", ",", "$", "comparison", "=", "Criteria", "::", "EQUAL", ")", "{", "return", "$", "this", "->", "useRolePermissionQuery", "(", ")", "->", "filterByRole", "(", "$", "role", ",", "$", "comparison", ")", "->", "endUse", "(", ")", ";", "}" ]
Filter the query by a related Role object using the role_permission table as cross reference @param Role $role the related object to use as filter @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildPermissionQuery The current query, for fluid interface
[ "Filter", "the", "query", "by", "a", "related", "Role", "object", "using", "the", "role_permission", "table", "as", "cross", "reference" ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/PermissionQuery.php#L742-L748
16,543
stubbles/stubbles-webapp-core
src/main/php/response/WebResponse.php
WebResponse.setStatusCode
public function setStatusCode(int $statusCode, string $reasonPhrase = null): Response { $this->status->setCode($statusCode, $reasonPhrase); return $this; }
php
public function setStatusCode(int $statusCode, string $reasonPhrase = null): Response { $this->status->setCode($statusCode, $reasonPhrase); return $this; }
[ "public", "function", "setStatusCode", "(", "int", "$", "statusCode", ",", "string", "$", "reasonPhrase", "=", "null", ")", ":", "Response", "{", "$", "this", "->", "status", "->", "setCode", "(", "$", "statusCode", ",", "$", "reasonPhrase", ")", ";", "return", "$", "this", ";", "}" ]
sets the status code to be send This needs only to be done if another status code then the default one 200 OK should be send. @param int $statusCode @param string $reasonPhrase optional @return \stubbles\webapp\Response
[ "sets", "the", "status", "code", "to", "be", "send" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/response/WebResponse.php#L136-L140
16,544
stubbles/stubbles-webapp-core
src/main/php/response/WebResponse.php
WebResponse.addHeader
public function addHeader(string $name, string $value): Response { $this->headers->add($name, $value); return $this; }
php
public function addHeader(string $name, string $value): Response { $this->headers->add($name, $value); return $this; }
[ "public", "function", "addHeader", "(", "string", "$", "name", ",", "string", "$", "value", ")", ":", "Response", "{", "$", "this", "->", "headers", "->", "add", "(", "$", "name", ",", "$", "value", ")", ";", "return", "$", "this", ";", "}" ]
add a header to the response @param string $name the name of the header @param string $value the value of the header @return \stubbles\webapp\Response
[ "add", "a", "header", "to", "the", "response" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/response/WebResponse.php#L171-L175
16,545
stubbles/stubbles-webapp-core
src/main/php/response/WebResponse.php
WebResponse.containsHeader
public function containsHeader(string $name, string $value = null): bool { if ($this->headers->contain($name)) { if (null !== $value) { return $value === $this->headers[$name]; } return true; } return false; }
php
public function containsHeader(string $name, string $value = null): bool { if ($this->headers->contain($name)) { if (null !== $value) { return $value === $this->headers[$name]; } return true; } return false; }
[ "public", "function", "containsHeader", "(", "string", "$", "name", ",", "string", "$", "value", "=", "null", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "headers", "->", "contain", "(", "$", "name", ")", ")", "{", "if", "(", "null", "!==", "$", "value", ")", "{", "return", "$", "value", "===", "$", "this", "->", "headers", "[", "$", "name", "]", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}" ]
check if response contains a certain header @param string $name name of header to check @param string $value optional if given the value is checked as well @return bool @since 4.0.0
[ "check", "if", "response", "contains", "a", "certain", "header" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/response/WebResponse.php#L196-L207
16,546
stubbles/stubbles-webapp-core
src/main/php/response/WebResponse.php
WebResponse.addCookie
public function addCookie(Cookie $cookie): Response { $this->cookies[$cookie->name()] = $cookie; return $this; }
php
public function addCookie(Cookie $cookie): Response { $this->cookies[$cookie->name()] = $cookie; return $this; }
[ "public", "function", "addCookie", "(", "Cookie", "$", "cookie", ")", ":", "Response", "{", "$", "this", "->", "cookies", "[", "$", "cookie", "->", "name", "(", ")", "]", "=", "$", "cookie", ";", "return", "$", "this", ";", "}" ]
add a cookie to the response @param \stubbles\webapp\response\Cookie $cookie the cookie to set @return \stubbles\webapp\Response
[ "add", "a", "cookie", "to", "the", "response" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/response/WebResponse.php#L215-L219
16,547
stubbles/stubbles-webapp-core
src/main/php/response/WebResponse.php
WebResponse.removeCookie
public function removeCookie(string $name): Response { $this->addCookie( Cookie::create($name, 'remove')->expiringAt(time() - 86400) ); return $this; }
php
public function removeCookie(string $name): Response { $this->addCookie( Cookie::create($name, 'remove')->expiringAt(time() - 86400) ); return $this; }
[ "public", "function", "removeCookie", "(", "string", "$", "name", ")", ":", "Response", "{", "$", "this", "->", "addCookie", "(", "Cookie", "::", "create", "(", "$", "name", ",", "'remove'", ")", "->", "expiringAt", "(", "time", "(", ")", "-", "86400", ")", ")", ";", "return", "$", "this", ";", "}" ]
removes cookie with given name @param string $name @return \stubbles\webapp\Response @since 2.0.0
[ "removes", "cookie", "with", "given", "name" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/response/WebResponse.php#L228-L234
16,548
stubbles/stubbles-webapp-core
src/main/php/response/WebResponse.php
WebResponse.containsCookie
public function containsCookie(string $name, string $value = null): bool { if (isset($this->cookies[$name])) { if (null !== $value) { return $this->cookies[$name]->value() === $value; } return true; } return false; }
php
public function containsCookie(string $name, string $value = null): bool { if (isset($this->cookies[$name])) { if (null !== $value) { return $this->cookies[$name]->value() === $value; } return true; } return false; }
[ "public", "function", "containsCookie", "(", "string", "$", "name", ",", "string", "$", "value", "=", "null", ")", ":", "bool", "{", "if", "(", "isset", "(", "$", "this", "->", "cookies", "[", "$", "name", "]", ")", ")", "{", "if", "(", "null", "!==", "$", "value", ")", "{", "return", "$", "this", "->", "cookies", "[", "$", "name", "]", "->", "value", "(", ")", "===", "$", "value", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}" ]
checks if response contains a certain cookie @param string $name name of cookie to check @param string $value optional if given the value is checked as well @return bool @since 4.0.0
[ "checks", "if", "response", "contains", "a", "certain", "cookie" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/response/WebResponse.php#L244-L255
16,549
stubbles/stubbles-webapp-core
src/main/php/response/WebResponse.php
WebResponse.methodNotAllowed
public function methodNotAllowed(string $requestMethod, array $allowedMethods): Error { $this->status->methodNotAllowed($allowedMethods); return Error::methodNotAllowed($requestMethod, $allowedMethods); }
php
public function methodNotAllowed(string $requestMethod, array $allowedMethods): Error { $this->status->methodNotAllowed($allowedMethods); return Error::methodNotAllowed($requestMethod, $allowedMethods); }
[ "public", "function", "methodNotAllowed", "(", "string", "$", "requestMethod", ",", "array", "$", "allowedMethods", ")", ":", "Error", "{", "$", "this", "->", "status", "->", "methodNotAllowed", "(", "$", "allowedMethods", ")", ";", "return", "Error", "::", "methodNotAllowed", "(", "$", "requestMethod", ",", "$", "allowedMethods", ")", ";", "}" ]
creates a 405 Method Not Allowed message @param string $requestMethod @param string[] $allowedMethods @return \stubbles\webapp\response\Error @since 2.0.0
[ "creates", "a", "405", "Method", "Not", "Allowed", "message" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/response/WebResponse.php#L334-L338
16,550
stubbles/stubbles-webapp-core
src/main/php/response/WebResponse.php
WebResponse.sendHead
private function sendHead(): Response { $this->header($this->status->line($this->version, $this->sapi)); foreach ($this->headers as $name => $value) { $this->header($name . ': ' . $value); } foreach ($this->cookies as $cookie) { $cookie->send(); } $this->header('Content-type: ' . $this->mimeType); if (!$this->headers->contain('X-Request-ID')) { $this->header('X-Request-ID: ' . $this->request->id()); } return $this; }
php
private function sendHead(): Response { $this->header($this->status->line($this->version, $this->sapi)); foreach ($this->headers as $name => $value) { $this->header($name . ': ' . $value); } foreach ($this->cookies as $cookie) { $cookie->send(); } $this->header('Content-type: ' . $this->mimeType); if (!$this->headers->contain('X-Request-ID')) { $this->header('X-Request-ID: ' . $this->request->id()); } return $this; }
[ "private", "function", "sendHead", "(", ")", ":", "Response", "{", "$", "this", "->", "header", "(", "$", "this", "->", "status", "->", "line", "(", "$", "this", "->", "version", ",", "$", "this", "->", "sapi", ")", ")", ";", "foreach", "(", "$", "this", "->", "headers", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "this", "->", "header", "(", "$", "name", ".", "': '", ".", "$", "value", ")", ";", "}", "foreach", "(", "$", "this", "->", "cookies", "as", "$", "cookie", ")", "{", "$", "cookie", "->", "send", "(", ")", ";", "}", "$", "this", "->", "header", "(", "'Content-type: '", ".", "$", "this", "->", "mimeType", ")", ";", "if", "(", "!", "$", "this", "->", "headers", "->", "contain", "(", "'X-Request-ID'", ")", ")", "{", "$", "this", "->", "header", "(", "'X-Request-ID: '", ".", "$", "this", "->", "request", "->", "id", "(", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
sends head only @return \stubbles\webapp\Response
[ "sends", "head", "only" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/response/WebResponse.php#L421-L438
16,551
FrenchFrogs/framework
src/Panel/Renderer/Bootstrap.php
Bootstrap.selectremote
public function selectremote(Panel\Action\SelectRemote $action) { $element = $action->getElement(); $element->addAttribute('id', $element->getName()); $element->addClass('select2-remote input-callback'); $element->addAttribute('data-css', 'form-control input-large input-sm'); $element->addAttribute('data-remote', $element->getUrl()); $element->addAttribute('data-length', $element->getLength()); $element->addAttribute('data-action', $action->getUrl()); $element->addAttribute('data-method', 'post'); $element->addAttribute('placeholder', $element->getLabel()); $html = html('input', $element->getAttributes()); return $html; }
php
public function selectremote(Panel\Action\SelectRemote $action) { $element = $action->getElement(); $element->addAttribute('id', $element->getName()); $element->addClass('select2-remote input-callback'); $element->addAttribute('data-css', 'form-control input-large input-sm'); $element->addAttribute('data-remote', $element->getUrl()); $element->addAttribute('data-length', $element->getLength()); $element->addAttribute('data-action', $action->getUrl()); $element->addAttribute('data-method', 'post'); $element->addAttribute('placeholder', $element->getLabel()); $html = html('input', $element->getAttributes()); return $html; }
[ "public", "function", "selectremote", "(", "Panel", "\\", "Action", "\\", "SelectRemote", "$", "action", ")", "{", "$", "element", "=", "$", "action", "->", "getElement", "(", ")", ";", "$", "element", "->", "addAttribute", "(", "'id'", ",", "$", "element", "->", "getName", "(", ")", ")", ";", "$", "element", "->", "addClass", "(", "'select2-remote input-callback'", ")", ";", "$", "element", "->", "addAttribute", "(", "'data-css'", ",", "'form-control input-large input-sm'", ")", ";", "$", "element", "->", "addAttribute", "(", "'data-remote'", ",", "$", "element", "->", "getUrl", "(", ")", ")", ";", "$", "element", "->", "addAttribute", "(", "'data-length'", ",", "$", "element", "->", "getLength", "(", ")", ")", ";", "$", "element", "->", "addAttribute", "(", "'data-action'", ",", "$", "action", "->", "getUrl", "(", ")", ")", ";", "$", "element", "->", "addAttribute", "(", "'data-method'", ",", "'post'", ")", ";", "$", "element", "->", "addAttribute", "(", "'placeholder'", ",", "$", "element", "->", "getLabel", "(", ")", ")", ";", "$", "html", "=", "html", "(", "'input'", ",", "$", "element", "->", "getAttributes", "(", ")", ")", ";", "return", "$", "html", ";", "}" ]
Render a Select 2 @param \FrenchFrogs\Panel\Action\SelectRemote $action
[ "Render", "a", "Select", "2" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Panel/Renderer/Bootstrap.php#L109-L123
16,552
datasift/datasift-php
lib/DataSift/Push/Subscription.php
DataSift_Push_Subscription.listSubscriptions
public static function listSubscriptions( $user, $page = 1, $per_page = 20, $order_by = self::ORDERBY_CREATED_AT, $order_dir = self::ORDERDIR_ASC, $include_finished = false, $hash_type = false, $hash = false ) { if ($page < 1) { throw new DataSift_Exception_InvalidData("The specified page number is invalid"); } if ($per_page < 1) { throw new DataSift_Exception_InvalidData("The specified per_page value is invalid"); } $params = array( 'page' => $page, 'per_page' => $per_page, 'order_by' => $order_by, 'order_dir' => $order_dir, ); if ($hash_type !== false && $hash !== false) { $params[$hash_type] = $hash; } if ($include_finished) { $params['include_finished'] = '1'; } $res = $user->post('push/get', $params); $retval = array('count' => $res['count'], 'subscriptions' => array()); foreach ($res['subscriptions'] as $sub) { $retval['subscriptions'][] = new self($user, $sub); } return $retval; }
php
public static function listSubscriptions( $user, $page = 1, $per_page = 20, $order_by = self::ORDERBY_CREATED_AT, $order_dir = self::ORDERDIR_ASC, $include_finished = false, $hash_type = false, $hash = false ) { if ($page < 1) { throw new DataSift_Exception_InvalidData("The specified page number is invalid"); } if ($per_page < 1) { throw new DataSift_Exception_InvalidData("The specified per_page value is invalid"); } $params = array( 'page' => $page, 'per_page' => $per_page, 'order_by' => $order_by, 'order_dir' => $order_dir, ); if ($hash_type !== false && $hash !== false) { $params[$hash_type] = $hash; } if ($include_finished) { $params['include_finished'] = '1'; } $res = $user->post('push/get', $params); $retval = array('count' => $res['count'], 'subscriptions' => array()); foreach ($res['subscriptions'] as $sub) { $retval['subscriptions'][] = new self($user, $sub); } return $retval; }
[ "public", "static", "function", "listSubscriptions", "(", "$", "user", ",", "$", "page", "=", "1", ",", "$", "per_page", "=", "20", ",", "$", "order_by", "=", "self", "::", "ORDERBY_CREATED_AT", ",", "$", "order_dir", "=", "self", "::", "ORDERDIR_ASC", ",", "$", "include_finished", "=", "false", ",", "$", "hash_type", "=", "false", ",", "$", "hash", "=", "false", ")", "{", "if", "(", "$", "page", "<", "1", ")", "{", "throw", "new", "DataSift_Exception_InvalidData", "(", "\"The specified page number is invalid\"", ")", ";", "}", "if", "(", "$", "per_page", "<", "1", ")", "{", "throw", "new", "DataSift_Exception_InvalidData", "(", "\"The specified per_page value is invalid\"", ")", ";", "}", "$", "params", "=", "array", "(", "'page'", "=>", "$", "page", ",", "'per_page'", "=>", "$", "per_page", ",", "'order_by'", "=>", "$", "order_by", ",", "'order_dir'", "=>", "$", "order_dir", ",", ")", ";", "if", "(", "$", "hash_type", "!==", "false", "&&", "$", "hash", "!==", "false", ")", "{", "$", "params", "[", "$", "hash_type", "]", "=", "$", "hash", ";", "}", "if", "(", "$", "include_finished", ")", "{", "$", "params", "[", "'include_finished'", "]", "=", "'1'", ";", "}", "$", "res", "=", "$", "user", "->", "post", "(", "'push/get'", ",", "$", "params", ")", ";", "$", "retval", "=", "array", "(", "'count'", "=>", "$", "res", "[", "'count'", "]", ",", "'subscriptions'", "=>", "array", "(", ")", ")", ";", "foreach", "(", "$", "res", "[", "'subscriptions'", "]", "as", "$", "sub", ")", "{", "$", "retval", "[", "'subscriptions'", "]", "[", "]", "=", "new", "self", "(", "$", "user", ",", "$", "sub", ")", ";", "}", "return", "$", "retval", ";", "}" ]
Get a page of push subscriptions in the given user's account, where each page contains up to per_page items. Results will be ordered according to the supplied ordering parameters. @param DataSift_User $user The user. @param int $page The page number to fetch. @param int $per_page The number of items per page. @param string $order_by The field on which to order the results. @param string $order_dir The direction of the ordering. @param boolean $include_finished True to include subscriptions against finished historic queries. @param string $hash_type Stream hash or Historics playback id. @param string $hash The stream hash or historics subscription id string. @return array Of DataSift_Push_Subscription objects. @throws DataSift_Exception_InvalidData @throws DataSift_Exception_APIError @throws DataSift_Exception_AccessDenied
[ "Get", "a", "page", "of", "push", "subscriptions", "in", "the", "given", "user", "s", "account", "where", "each", "page", "contains", "up", "to", "per_page", "items", ".", "Results", "will", "be", "ordered", "according", "to", "the", "supplied", "ordering", "parameters", "." ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Push/Subscription.php#L94-L135
16,553
datasift/datasift-php
lib/DataSift/Push/Subscription.php
DataSift_Push_Subscription.listByPlaybackId
public static function listByPlaybackId( $user, $playback_id, $page = 1, $per_page = 20, $order_by = self::ORDERBY_CREATED_AT, $order_dir = self::ORDERDIR_ASC, $include_finished = false, $hash_type = false, $hash = false ) { return self::listSubscriptions( $user, $page, $per_page, $order_by, $order_dir, $include_finished, 'playback_id', $playback_id ); }
php
public static function listByPlaybackId( $user, $playback_id, $page = 1, $per_page = 20, $order_by = self::ORDERBY_CREATED_AT, $order_dir = self::ORDERDIR_ASC, $include_finished = false, $hash_type = false, $hash = false ) { return self::listSubscriptions( $user, $page, $per_page, $order_by, $order_dir, $include_finished, 'playback_id', $playback_id ); }
[ "public", "static", "function", "listByPlaybackId", "(", "$", "user", ",", "$", "playback_id", ",", "$", "page", "=", "1", ",", "$", "per_page", "=", "20", ",", "$", "order_by", "=", "self", "::", "ORDERBY_CREATED_AT", ",", "$", "order_dir", "=", "self", "::", "ORDERDIR_ASC", ",", "$", "include_finished", "=", "false", ",", "$", "hash_type", "=", "false", ",", "$", "hash", "=", "false", ")", "{", "return", "self", "::", "listSubscriptions", "(", "$", "user", ",", "$", "page", ",", "$", "per_page", ",", "$", "order_by", ",", "$", "order_dir", ",", "$", "include_finished", ",", "'playback_id'", ",", "$", "playback_id", ")", ";", "}" ]
Get a page of push subscriptions to the given stream playback_id, where each page contains up to per_page items. Results will be ordered according to the supplied ordering parameters. @param DataSift_User $user The user. @param string $playback_id The Historics playback ID. @param int $page The page number to fetch. @param int $per_page The number of items per page. @param string $order_by The field on which to order the results. @param string $order_dir The direction of the ordering. @param boolean $include_finished True to include subscriptions against @param string $hash_type Stream hash or Historics playback id. @param string $hash The stream hash. finished historic queries. @return array Of DataSift_Push_Subscription objects. @throws DataSift_Exception_InvalidData @throws DataSift_Exception_APIError @throws DataSift_Exception_AccessDenied
[ "Get", "a", "page", "of", "push", "subscriptions", "to", "the", "given", "stream", "playback_id", "where", "each", "page", "contains", "up", "to", "per_page", "items", ".", "Results", "will", "be", "ordered", "according", "to", "the", "supplied", "ordering", "parameters", "." ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Push/Subscription.php#L200-L221
16,554
datasift/datasift-php
lib/DataSift/Push/Subscription.php
DataSift_Push_Subscription.init
protected function init($data) { if (! isset($data['id'])) { throw new DataSift_Exception_InvalidData('No id found'); } $this->_id = $data['id']; if (! isset($data['name'])) { throw new DataSift_Exception_InvalidData('No name found'); } $this->_name = $data['name']; if (! isset($data['created_at'])) { throw new DataSift_Exception_InvalidData('No created_at found'); } $this->_created_at = $data['created_at']; if (! isset($data['status'])) { throw new DataSift_Exception_InvalidData('No status found'); } $this->_status = $data['status']; if (! isset($data['hash_type'], $data)) { throw new DataSift_Exception_InvalidData('No hash_type found'); } $this->_hash_type = $data['hash_type']; if (! isset($data['hash'])) { throw new DataSift_Exception_InvalidData('No hash found'); } $this->_hash = $data['hash']; if (! isset($data['last_request'])) { $this->_last_request = 0; } else { $this->_last_request = $data['last_request']; } if (! isset($data['last_success'])) { $this->_last_success = 0; } else { $this->_last_success = $data['last_success']; } if (! isset($data['output_type'])) { throw new DataSift_Exception_InvalidData('No output_type found'); } $this->_output_type = $data['output_type']; if (! isset($data['output_params'])) { throw new DataSift_Exception_InvalidData('No output_params found'); } $this->_output_params = $this->parseOutputParams($data['output_params']); }
php
protected function init($data) { if (! isset($data['id'])) { throw new DataSift_Exception_InvalidData('No id found'); } $this->_id = $data['id']; if (! isset($data['name'])) { throw new DataSift_Exception_InvalidData('No name found'); } $this->_name = $data['name']; if (! isset($data['created_at'])) { throw new DataSift_Exception_InvalidData('No created_at found'); } $this->_created_at = $data['created_at']; if (! isset($data['status'])) { throw new DataSift_Exception_InvalidData('No status found'); } $this->_status = $data['status']; if (! isset($data['hash_type'], $data)) { throw new DataSift_Exception_InvalidData('No hash_type found'); } $this->_hash_type = $data['hash_type']; if (! isset($data['hash'])) { throw new DataSift_Exception_InvalidData('No hash found'); } $this->_hash = $data['hash']; if (! isset($data['last_request'])) { $this->_last_request = 0; } else { $this->_last_request = $data['last_request']; } if (! isset($data['last_success'])) { $this->_last_success = 0; } else { $this->_last_success = $data['last_success']; } if (! isset($data['output_type'])) { throw new DataSift_Exception_InvalidData('No output_type found'); } $this->_output_type = $data['output_type']; if (! isset($data['output_params'])) { throw new DataSift_Exception_InvalidData('No output_params found'); } $this->_output_params = $this->parseOutputParams($data['output_params']); }
[ "protected", "function", "init", "(", "$", "data", ")", "{", "if", "(", "!", "isset", "(", "$", "data", "[", "'id'", "]", ")", ")", "{", "throw", "new", "DataSift_Exception_InvalidData", "(", "'No id found'", ")", ";", "}", "$", "this", "->", "_id", "=", "$", "data", "[", "'id'", "]", ";", "if", "(", "!", "isset", "(", "$", "data", "[", "'name'", "]", ")", ")", "{", "throw", "new", "DataSift_Exception_InvalidData", "(", "'No name found'", ")", ";", "}", "$", "this", "->", "_name", "=", "$", "data", "[", "'name'", "]", ";", "if", "(", "!", "isset", "(", "$", "data", "[", "'created_at'", "]", ")", ")", "{", "throw", "new", "DataSift_Exception_InvalidData", "(", "'No created_at found'", ")", ";", "}", "$", "this", "->", "_created_at", "=", "$", "data", "[", "'created_at'", "]", ";", "if", "(", "!", "isset", "(", "$", "data", "[", "'status'", "]", ")", ")", "{", "throw", "new", "DataSift_Exception_InvalidData", "(", "'No status found'", ")", ";", "}", "$", "this", "->", "_status", "=", "$", "data", "[", "'status'", "]", ";", "if", "(", "!", "isset", "(", "$", "data", "[", "'hash_type'", "]", ",", "$", "data", ")", ")", "{", "throw", "new", "DataSift_Exception_InvalidData", "(", "'No hash_type found'", ")", ";", "}", "$", "this", "->", "_hash_type", "=", "$", "data", "[", "'hash_type'", "]", ";", "if", "(", "!", "isset", "(", "$", "data", "[", "'hash'", "]", ")", ")", "{", "throw", "new", "DataSift_Exception_InvalidData", "(", "'No hash found'", ")", ";", "}", "$", "this", "->", "_hash", "=", "$", "data", "[", "'hash'", "]", ";", "if", "(", "!", "isset", "(", "$", "data", "[", "'last_request'", "]", ")", ")", "{", "$", "this", "->", "_last_request", "=", "0", ";", "}", "else", "{", "$", "this", "->", "_last_request", "=", "$", "data", "[", "'last_request'", "]", ";", "}", "if", "(", "!", "isset", "(", "$", "data", "[", "'last_success'", "]", ")", ")", "{", "$", "this", "->", "_last_success", "=", "0", ";", "}", "else", "{", "$", "this", "->", "_last_success", "=", "$", "data", "[", "'last_success'", "]", ";", "}", "if", "(", "!", "isset", "(", "$", "data", "[", "'output_type'", "]", ")", ")", "{", "throw", "new", "DataSift_Exception_InvalidData", "(", "'No output_type found'", ")", ";", "}", "$", "this", "->", "_output_type", "=", "$", "data", "[", "'output_type'", "]", ";", "if", "(", "!", "isset", "(", "$", "data", "[", "'output_params'", "]", ")", ")", "{", "throw", "new", "DataSift_Exception_InvalidData", "(", "'No output_params found'", ")", ";", "}", "$", "this", "->", "_output_params", "=", "$", "this", "->", "parseOutputParams", "(", "$", "data", "[", "'output_params'", "]", ")", ";", "}" ]
Extract data from an array. @param array $data An array containing the subscription data. @throws DataSift_Exception_InvalidData
[ "Extract", "data", "from", "an", "array", "." ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Push/Subscription.php#L342-L395
16,555
datasift/datasift-php
lib/DataSift/Push/Subscription.php
DataSift_Push_Subscription.parseOutputParams
protected function parseOutputParams($params, $prefix = '') { $retval = array(); foreach ($params as $key => $val) { if (is_array($val)) { $retval = array_merge($retval, $this->parseOutputParams($val, $prefix . $key . '.')); } else { $retval[$prefix . $key] = $val; } } return $retval; }
php
protected function parseOutputParams($params, $prefix = '') { $retval = array(); foreach ($params as $key => $val) { if (is_array($val)) { $retval = array_merge($retval, $this->parseOutputParams($val, $prefix . $key . '.')); } else { $retval[$prefix . $key] = $val; } } return $retval; }
[ "protected", "function", "parseOutputParams", "(", "$", "params", ",", "$", "prefix", "=", "''", ")", "{", "$", "retval", "=", "array", "(", ")", ";", "foreach", "(", "$", "params", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "is_array", "(", "$", "val", ")", ")", "{", "$", "retval", "=", "array_merge", "(", "$", "retval", ",", "$", "this", "->", "parseOutputParams", "(", "$", "val", ",", "$", "prefix", ".", "$", "key", ".", "'.'", ")", ")", ";", "}", "else", "{", "$", "retval", "[", "$", "prefix", ".", "$", "key", "]", "=", "$", "val", ";", "}", "}", "return", "$", "retval", ";", "}" ]
Recursive method to parse the output_params as received from the API into the flattened, dot-notation used by the client libraries. @param array $params The parameters to parse. @param string $prefix The current key prefix. @return array
[ "Recursive", "method", "to", "parse", "the", "output_params", "as", "received", "from", "the", "API", "into", "the", "flattened", "dot", "-", "notation", "used", "by", "the", "client", "libraries", "." ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Push/Subscription.php#L406-L417
16,556
datasift/datasift-php
lib/DataSift/Push/Subscription.php
DataSift_Push_Subscription.setOutputParam
public function setOutputParam($key, $val) { if ($this->isDeleted()) { throw new DataSift_Exception_InvalidData('Cannot modify a deleted subscription'); } parent::setOutputParam($key, $val); }
php
public function setOutputParam($key, $val) { if ($this->isDeleted()) { throw new DataSift_Exception_InvalidData('Cannot modify a deleted subscription'); } parent::setOutputParam($key, $val); }
[ "public", "function", "setOutputParam", "(", "$", "key", ",", "$", "val", ")", "{", "if", "(", "$", "this", "->", "isDeleted", "(", ")", ")", "{", "throw", "new", "DataSift_Exception_InvalidData", "(", "'Cannot modify a deleted subscription'", ")", ";", "}", "parent", "::", "setOutputParam", "(", "$", "key", ",", "$", "val", ")", ";", "}" ]
Set an output parameter. Checks to see if the subscription has been deleted, and if not calls the base class to set the parameter. @param string $key The output parameter to set. @param string $val The value to which to set it. @throws DataSift_Exception_InvalidData
[ "Set", "an", "output", "parameter", ".", "Checks", "to", "see", "if", "the", "subscription", "has", "been", "deleted", "and", "if", "not", "calls", "the", "base", "class", "to", "set", "the", "parameter", "." ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Push/Subscription.php#L460-L466
16,557
datasift/datasift-php
lib/DataSift/Push/Subscription.php
DataSift_Push_Subscription.save
public function save() { // Can only update the name and output_params $params = array('id' => $this->getId(), 'name' => $this->getName()); foreach ($this->_output_params as $key => $val) { $params[DataSift_Push_Definition::OUTPUT_PARAMS_PREFIX . $key] = $val; } // Call the API and pass the returned object into init to update this object $this->init($this->_user->post('push/update', $params)); }
php
public function save() { // Can only update the name and output_params $params = array('id' => $this->getId(), 'name' => $this->getName()); foreach ($this->_output_params as $key => $val) { $params[DataSift_Push_Definition::OUTPUT_PARAMS_PREFIX . $key] = $val; } // Call the API and pass the returned object into init to update this object $this->init($this->_user->post('push/update', $params)); }
[ "public", "function", "save", "(", ")", "{", "// Can only update the name and output_params", "$", "params", "=", "array", "(", "'id'", "=>", "$", "this", "->", "getId", "(", ")", ",", "'name'", "=>", "$", "this", "->", "getName", "(", ")", ")", ";", "foreach", "(", "$", "this", "->", "_output_params", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "params", "[", "DataSift_Push_Definition", "::", "OUTPUT_PARAMS_PREFIX", ".", "$", "key", "]", "=", "$", "val", ";", "}", "// Call the API and pass the returned object into init to update this object", "$", "this", "->", "init", "(", "$", "this", "->", "_user", "->", "post", "(", "'push/update'", ",", "$", "params", ")", ")", ";", "}" ]
Save changes to the name and output_parameters of this subscription. @throws DataSift_Exception_InvalidData @throws DataSift_Exception_APIError @throws DataSift_Exception_AccessDenied
[ "Save", "changes", "to", "the", "name", "and", "output_parameters", "of", "this", "subscription", "." ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Push/Subscription.php#L557-L567
16,558
datasift/datasift-php
lib/DataSift/Push/Subscription.php
DataSift_Push_Subscription.delete
public function delete() { $this->_user->post('push/delete', array('id' => $this->getId())); // The delete API call doesn't return the object, so set the status // manually $this->_status = self::STATUS_DELETED; }
php
public function delete() { $this->_user->post('push/delete', array('id' => $this->getId())); // The delete API call doesn't return the object, so set the status // manually $this->_status = self::STATUS_DELETED; }
[ "public", "function", "delete", "(", ")", "{", "$", "this", "->", "_user", "->", "post", "(", "'push/delete'", ",", "array", "(", "'id'", "=>", "$", "this", "->", "getId", "(", ")", ")", ")", ";", "// The delete API call doesn't return the object, so set the status", "// manually", "$", "this", "->", "_status", "=", "self", "::", "STATUS_DELETED", ";", "}" ]
Delete this subscription. @throws DataSift_Exception_APIError @throws DataSift_Exception_AccessDenied
[ "Delete", "this", "subscription", "." ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Push/Subscription.php#L611-L617
16,559
datasift/datasift-php
lib/DataSift/Push/Subscription.php
DataSift_Push_Subscription.pull
public function pull($size = 20971520, $cursor = false) { //Check that the output type of this subscription is a pull if (strtolower($this->_output_type) != 'pull') { throw new DataSift_Exception_InvalidData("Output type is not pull"); } $params = array('id' => $this->getId(), 'size' => $size); if ($cursor !== false) { $params['cursor'] = $cursor; } return $this->_user->get('pull', $params); }
php
public function pull($size = 20971520, $cursor = false) { //Check that the output type of this subscription is a pull if (strtolower($this->_output_type) != 'pull') { throw new DataSift_Exception_InvalidData("Output type is not pull"); } $params = array('id' => $this->getId(), 'size' => $size); if ($cursor !== false) { $params['cursor'] = $cursor; } return $this->_user->get('pull', $params); }
[ "public", "function", "pull", "(", "$", "size", "=", "20971520", ",", "$", "cursor", "=", "false", ")", "{", "//Check that the output type of this subscription is a pull", "if", "(", "strtolower", "(", "$", "this", "->", "_output_type", ")", "!=", "'pull'", ")", "{", "throw", "new", "DataSift_Exception_InvalidData", "(", "\"Output type is not pull\"", ")", ";", "}", "$", "params", "=", "array", "(", "'id'", "=>", "$", "this", "->", "getId", "(", ")", ",", "'size'", "=>", "$", "size", ")", ";", "if", "(", "$", "cursor", "!==", "false", ")", "{", "$", "params", "[", "'cursor'", "]", "=", "$", "cursor", ";", "}", "return", "$", "this", "->", "_user", "->", "get", "(", "'pull'", ",", "$", "params", ")", ";", "}" ]
Pull data from this subscription. @param int $size The maximum amount of data that DataSift will send in a single batch. Can be any value from 1 byte through 20971520 bytes. @param string $cursor A pointer into the Push queue associated with the current Push subscription. @return array @throws DataSift_Exception_InvalidData @throws DataSift_Exception_APIError @throws DataSift_Exception_AccessDenied
[ "Pull", "data", "from", "this", "subscription", "." ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Push/Subscription.php#L631-L645
16,560
datasift/datasift-php
lib/DataSift/Push/Subscription.php
DataSift_Push_Subscription.getLog
public function getLog( $page = 1, $per_page = 20, $order_by = self::ORDERBY_REQUEST_TIME, $order_dir = self::ORDERDIR_DESC ) { return self::getLogs($this->_user, $page, $per_page, $order_by, $order_dir, $this->getId()); }
php
public function getLog( $page = 1, $per_page = 20, $order_by = self::ORDERBY_REQUEST_TIME, $order_dir = self::ORDERDIR_DESC ) { return self::getLogs($this->_user, $page, $per_page, $order_by, $order_dir, $this->getId()); }
[ "public", "function", "getLog", "(", "$", "page", "=", "1", ",", "$", "per_page", "=", "20", ",", "$", "order_by", "=", "self", "::", "ORDERBY_REQUEST_TIME", ",", "$", "order_dir", "=", "self", "::", "ORDERDIR_DESC", ")", "{", "return", "self", "::", "getLogs", "(", "$", "this", "->", "_user", ",", "$", "page", ",", "$", "per_page", ",", "$", "order_by", ",", "$", "order_dir", ",", "$", "this", "->", "getId", "(", ")", ")", ";", "}" ]
Get a page of the log for this subscription order as specified. @param int $page The page to get. @param int $per_page The number of entries per page. @param string $order_by By which field to order the entries. @param string $order_dir The direction of the sorting ("asc" or "desc"). @return array @throws DataSift_Exception_APIError @throws DataSift_Exception_InvalidData @throws DataSift_Exception_AccessDenied
[ "Get", "a", "page", "of", "the", "log", "for", "this", "subscription", "order", "as", "specified", "." ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/Push/Subscription.php#L660-L667
16,561
JoffreyPoreeCoding/MongoDB-ODM
src/Iterator/DocumentIterator.php
DocumentIterator.rewind
public function rewind() { if (!$this->rewindable && !$this->firstCross) { throw new \Exception('Unable to traverse not rewindable iterator multiple time'); } $this->firstCross = false; $this->position = 0; }
php
public function rewind() { if (!$this->rewindable && !$this->firstCross) { throw new \Exception('Unable to traverse not rewindable iterator multiple time'); } $this->firstCross = false; $this->position = 0; }
[ "public", "function", "rewind", "(", ")", "{", "if", "(", "!", "$", "this", "->", "rewindable", "&&", "!", "$", "this", "->", "firstCross", ")", "{", "throw", "new", "\\", "Exception", "(", "'Unable to traverse not rewindable iterator multiple time'", ")", ";", "}", "$", "this", "->", "firstCross", "=", "false", ";", "$", "this", "->", "position", "=", "0", ";", "}" ]
Rewinds the Iterator to the first element. @return void
[ "Rewinds", "the", "Iterator", "to", "the", "first", "element", "." ]
56fd7ab28c22f276573a89d56bb93c8d74ad7f74
https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/Iterator/DocumentIterator.php#L154-L161
16,562
JoffreyPoreeCoding/MongoDB-ODM
src/Iterator/DocumentIterator.php
DocumentIterator.count
public function count() { if (!isset($this->count)) { $this->count = $this->repository->count($this->query); } return $this->count; }
php
public function count() { if (!isset($this->count)) { $this->count = $this->repository->count($this->query); } return $this->count; }
[ "public", "function", "count", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "count", ")", ")", "{", "$", "this", "->", "count", "=", "$", "this", "->", "repository", "->", "count", "(", "$", "this", "->", "query", ")", ";", "}", "return", "$", "this", "->", "count", ";", "}" ]
Count number of document from collection @return integer
[ "Count", "number", "of", "document", "from", "collection" ]
56fd7ab28c22f276573a89d56bb93c8d74ad7f74
https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/Iterator/DocumentIterator.php#L260-L266
16,563
belgattitude/soluble-metadata
src/Soluble/Metadata/Reader/PdoMysqlMetadataReader.php
PdoMysqlMetadataReader.readFields
protected function readFields(string $sql): array { if (trim($sql) === '') { throw new Exception\EmptyQueryException('Cannot read fields for an empty query'); } $sql = $this->getEmptiedQuery($sql); $stmt = $this->pdo->prepare($sql); if ($stmt->execute() !== true) { throw new Exception\InvalidQueryException( sprintf('Invalid query: %s', $sql) ); } $column_count = $stmt->columnCount(); $metaFields = []; for ($i = 0; $i < $column_count; ++$i) { $meta = $stmt->getColumnMeta($i); $metaFields[$i] = $meta; } $stmt->closeCursor(); unset($stmt); return $metaFields; }
php
protected function readFields(string $sql): array { if (trim($sql) === '') { throw new Exception\EmptyQueryException('Cannot read fields for an empty query'); } $sql = $this->getEmptiedQuery($sql); $stmt = $this->pdo->prepare($sql); if ($stmt->execute() !== true) { throw new Exception\InvalidQueryException( sprintf('Invalid query: %s', $sql) ); } $column_count = $stmt->columnCount(); $metaFields = []; for ($i = 0; $i < $column_count; ++$i) { $meta = $stmt->getColumnMeta($i); $metaFields[$i] = $meta; } $stmt->closeCursor(); unset($stmt); return $metaFields; }
[ "protected", "function", "readFields", "(", "string", "$", "sql", ")", ":", "array", "{", "if", "(", "trim", "(", "$", "sql", ")", "===", "''", ")", "{", "throw", "new", "Exception", "\\", "EmptyQueryException", "(", "'Cannot read fields for an empty query'", ")", ";", "}", "$", "sql", "=", "$", "this", "->", "getEmptiedQuery", "(", "$", "sql", ")", ";", "$", "stmt", "=", "$", "this", "->", "pdo", "->", "prepare", "(", "$", "sql", ")", ";", "if", "(", "$", "stmt", "->", "execute", "(", ")", "!==", "true", ")", "{", "throw", "new", "Exception", "\\", "InvalidQueryException", "(", "sprintf", "(", "'Invalid query: %s'", ",", "$", "sql", ")", ")", ";", "}", "$", "column_count", "=", "$", "stmt", "->", "columnCount", "(", ")", ";", "$", "metaFields", "=", "[", "]", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "column_count", ";", "++", "$", "i", ")", "{", "$", "meta", "=", "$", "stmt", "->", "getColumnMeta", "(", "$", "i", ")", ";", "$", "metaFields", "[", "$", "i", "]", "=", "$", "meta", ";", "}", "$", "stmt", "->", "closeCursor", "(", ")", ";", "unset", "(", "$", "stmt", ")", ";", "return", "$", "metaFields", ";", "}" ]
Read fields from pdo source. @return array<int, array> @throws Exception\ConnectionException @throws \Soluble\Metadata\Exception\EmptyQueryException @throws \Soluble\Metadata\Exception\InvalidQueryException
[ "Read", "fields", "from", "pdo", "source", "." ]
6285461c40a619070f601184d58e6c772b769d5c
https://github.com/belgattitude/soluble-metadata/blob/6285461c40a619070f601184d58e6c772b769d5c/src/Soluble/Metadata/Reader/PdoMysqlMetadataReader.php#L159-L185
16,564
WellCommerce/OrderBundle
Calculator/SalesSummaryCalculator.php
SalesSummaryCalculator.filterCurrentItems
protected function filterCurrentItems(Collection $collection) { $endDate = new DateTime(); $format = $this->configuration->getGroupByDateFormat(); $identifier = $endDate->format($format); return $collection->filter(function (ReportRow $row) use ($identifier) { return $row->getIdentifier() === $identifier; }); }
php
protected function filterCurrentItems(Collection $collection) { $endDate = new DateTime(); $format = $this->configuration->getGroupByDateFormat(); $identifier = $endDate->format($format); return $collection->filter(function (ReportRow $row) use ($identifier) { return $row->getIdentifier() === $identifier; }); }
[ "protected", "function", "filterCurrentItems", "(", "Collection", "$", "collection", ")", "{", "$", "endDate", "=", "new", "DateTime", "(", ")", ";", "$", "format", "=", "$", "this", "->", "configuration", "->", "getGroupByDateFormat", "(", ")", ";", "$", "identifier", "=", "$", "endDate", "->", "format", "(", "$", "format", ")", ";", "return", "$", "collection", "->", "filter", "(", "function", "(", "ReportRow", "$", "row", ")", "use", "(", "$", "identifier", ")", "{", "return", "$", "row", "->", "getIdentifier", "(", ")", "===", "$", "identifier", ";", "}", ")", ";", "}" ]
Filters a collection to get only current items @param Collection $collection @return Collection
[ "Filters", "a", "collection", "to", "get", "only", "current", "items" ]
d72cfb51eab7a1f66f186900d1e2d533a822c424
https://github.com/WellCommerce/OrderBundle/blob/d72cfb51eab7a1f66f186900d1e2d533a822c424/Calculator/SalesSummaryCalculator.php#L85-L94
16,565
geosocio/http-serializer-bundle
src/DependencyInjection/Compiler/GroupResolverPass.php
GroupResolverPass.addResolvers
protected function addResolvers(ContainerBuilder $container, string $service, string $tag) { if (!$container->has($service)) { return; } $definition = $container->getDefinition($service); $taggedServices = $container->findTaggedServiceIds($tag); foreach ($taggedServices as $id => $tags) { foreach ($tags as $attributes) { $definition->addMethodCall('addResolver', [ new Reference($id) ]); } } }
php
protected function addResolvers(ContainerBuilder $container, string $service, string $tag) { if (!$container->has($service)) { return; } $definition = $container->getDefinition($service); $taggedServices = $container->findTaggedServiceIds($tag); foreach ($taggedServices as $id => $tags) { foreach ($tags as $attributes) { $definition->addMethodCall('addResolver', [ new Reference($id) ]); } } }
[ "protected", "function", "addResolvers", "(", "ContainerBuilder", "$", "container", ",", "string", "$", "service", ",", "string", "$", "tag", ")", "{", "if", "(", "!", "$", "container", "->", "has", "(", "$", "service", ")", ")", "{", "return", ";", "}", "$", "definition", "=", "$", "container", "->", "getDefinition", "(", "$", "service", ")", ";", "$", "taggedServices", "=", "$", "container", "->", "findTaggedServiceIds", "(", "$", "tag", ")", ";", "foreach", "(", "$", "taggedServices", "as", "$", "id", "=>", "$", "tags", ")", "{", "foreach", "(", "$", "tags", "as", "$", "attributes", ")", "{", "$", "definition", "->", "addMethodCall", "(", "'addResolver'", ",", "[", "new", "Reference", "(", "$", "id", ")", "]", ")", ";", "}", "}", "}" ]
Add the Resolvers. @param ContainerBuilder $container @param string $service @param string $tag @return void
[ "Add", "the", "Resolvers", "." ]
2ceb24a148204b1f3b14083b202db7e5afff2099
https://github.com/geosocio/http-serializer-bundle/blob/2ceb24a148204b1f3b14083b202db7e5afff2099/src/DependencyInjection/Compiler/GroupResolverPass.php#L40-L56
16,566
jasny/router
src/Router/Runner/Callback.php
Callback.run
public function run(ServerRequestInterface $request, ResponseInterface $response) { $route = $request->getAttribute('route'); $callback = !empty($route->fn) ? $route->fn : null; if (!is_callable($callback)) { trigger_error("'fn' property of route shoud be a callable", E_USER_NOTICE); return $this->notFound($request, $response); } return $callback($request, $response); }
php
public function run(ServerRequestInterface $request, ResponseInterface $response) { $route = $request->getAttribute('route'); $callback = !empty($route->fn) ? $route->fn : null; if (!is_callable($callback)) { trigger_error("'fn' property of route shoud be a callable", E_USER_NOTICE); return $this->notFound($request, $response); } return $callback($request, $response); }
[ "public", "function", "run", "(", "ServerRequestInterface", "$", "request", ",", "ResponseInterface", "$", "response", ")", "{", "$", "route", "=", "$", "request", "->", "getAttribute", "(", "'route'", ")", ";", "$", "callback", "=", "!", "empty", "(", "$", "route", "->", "fn", ")", "?", "$", "route", "->", "fn", ":", "null", ";", "if", "(", "!", "is_callable", "(", "$", "callback", ")", ")", "{", "trigger_error", "(", "\"'fn' property of route shoud be a callable\"", ",", "E_USER_NOTICE", ")", ";", "return", "$", "this", "->", "notFound", "(", "$", "request", ",", "$", "response", ")", ";", "}", "return", "$", "callback", "(", "$", "request", ",", "$", "response", ")", ";", "}" ]
Use function to handle request and response @param ServerRequestInterface $request @param ResponseInterface $response @return ResponseInterface|mixed
[ "Use", "function", "to", "handle", "request", "and", "response" ]
4c776665ba343150b442c21893946e3d54190896
https://github.com/jasny/router/blob/4c776665ba343150b442c21893946e3d54190896/src/Router/Runner/Callback.php#L23-L34
16,567
stubbles/stubbles-webapp-core
src/main/php/response/Error.php
Error.methodNotAllowed
public static function methodNotAllowed(string $requestMethod, array $allowedMethods): self { return new self( 'The given request method ' . strtoupper($requestMethod) . ' is not valid. Please use one of ' . join(', ', $allowedMethods) . '.', 'Method Not Allowed' ); }
php
public static function methodNotAllowed(string $requestMethod, array $allowedMethods): self { return new self( 'The given request method ' . strtoupper($requestMethod) . ' is not valid. Please use one of ' . join(', ', $allowedMethods) . '.', 'Method Not Allowed' ); }
[ "public", "static", "function", "methodNotAllowed", "(", "string", "$", "requestMethod", ",", "array", "$", "allowedMethods", ")", ":", "self", "{", "return", "new", "self", "(", "'The given request method '", ".", "strtoupper", "(", "$", "requestMethod", ")", ".", "' is not valid. Please use one of '", ".", "join", "(", "', '", ",", "$", "allowedMethods", ")", ".", "'.'", ",", "'Method Not Allowed'", ")", ";", "}" ]
creates error when access to resource with request method is not allowed @param string $requestMethod actual request method @param string[] $allowedMethods list of allowed request methods @return \stubbles\webapp\response\Error
[ "creates", "error", "when", "access", "to", "resource", "with", "request", "method", "is", "not", "allowed" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/response/Error.php#L74-L83
16,568
stubbles/stubbles-webapp-core
src/main/php/response/Error.php
Error.inParams
public static function inParams(ParamErrors $errors, ParamErrorMessages $errorMessages): self { return new self(Sequence::of($errors)->map( function(array $errors, $paramName) use ($errorMessages): array { $resolved = ['field' => $paramName, 'errors' => []]; foreach ($errors as $id => $error) { $resolved['errors'][] = [ 'id' => $id, 'details' => $error->details(), 'message' => $errorMessages->messageFor($error)->message() ]; } return $resolved; } )); }
php
public static function inParams(ParamErrors $errors, ParamErrorMessages $errorMessages): self { return new self(Sequence::of($errors)->map( function(array $errors, $paramName) use ($errorMessages): array { $resolved = ['field' => $paramName, 'errors' => []]; foreach ($errors as $id => $error) { $resolved['errors'][] = [ 'id' => $id, 'details' => $error->details(), 'message' => $errorMessages->messageFor($error)->message() ]; } return $resolved; } )); }
[ "public", "static", "function", "inParams", "(", "ParamErrors", "$", "errors", ",", "ParamErrorMessages", "$", "errorMessages", ")", ":", "self", "{", "return", "new", "self", "(", "Sequence", "::", "of", "(", "$", "errors", ")", "->", "map", "(", "function", "(", "array", "$", "errors", ",", "$", "paramName", ")", "use", "(", "$", "errorMessages", ")", ":", "array", "{", "$", "resolved", "=", "[", "'field'", "=>", "$", "paramName", ",", "'errors'", "=>", "[", "]", "]", ";", "foreach", "(", "$", "errors", "as", "$", "id", "=>", "$", "error", ")", "{", "$", "resolved", "[", "'errors'", "]", "[", "]", "=", "[", "'id'", "=>", "$", "id", ",", "'details'", "=>", "$", "error", "->", "details", "(", ")", ",", "'message'", "=>", "$", "errorMessages", "->", "messageFor", "(", "$", "error", ")", "->", "message", "(", ")", "]", ";", "}", "return", "$", "resolved", ";", "}", ")", ")", ";", "}" ]
creates error with given list of param errors @param \stubbles\input\errors\ParamErrors $errors @param \stubbles\webapp\response\ParamErrorMessages $errorMessages @return self @since 6.2.0
[ "creates", "error", "with", "given", "list", "of", "param", "errors" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/response/Error.php#L141-L158
16,569
prooph/link-app-core
src/Model/ProcessingConfig.php
ProcessingConfig.initializeWithDefaultsIn
public static function initializeWithDefaultsIn(ConfigLocation $configLocation, ConfigWriter $configWriter) { $env = Environment::setUp(); $instance = new self(['processing' => array_merge( $env->getConfig()->toArray(), [ "connectors" => [], "js_ticker" => ['enabled' => false, 'interval' => 3], ] )], $configLocation); $configFilePath = $configLocation->toString() . DIRECTORY_SEPARATOR . self::$configFileName; if (file_exists($configFilePath)) { throw new \RuntimeException("Processing config already exists: " . $configFilePath); } $configWriter->writeNewConfigToDirectory($instance->toArray(), $configFilePath); $instance->recordThat(ProcessingConfigFileWasCreated::in($configLocation, self::$configFileName)); return $instance; }
php
public static function initializeWithDefaultsIn(ConfigLocation $configLocation, ConfigWriter $configWriter) { $env = Environment::setUp(); $instance = new self(['processing' => array_merge( $env->getConfig()->toArray(), [ "connectors" => [], "js_ticker" => ['enabled' => false, 'interval' => 3], ] )], $configLocation); $configFilePath = $configLocation->toString() . DIRECTORY_SEPARATOR . self::$configFileName; if (file_exists($configFilePath)) { throw new \RuntimeException("Processing config already exists: " . $configFilePath); } $configWriter->writeNewConfigToDirectory($instance->toArray(), $configFilePath); $instance->recordThat(ProcessingConfigFileWasCreated::in($configLocation, self::$configFileName)); return $instance; }
[ "public", "static", "function", "initializeWithDefaultsIn", "(", "ConfigLocation", "$", "configLocation", ",", "ConfigWriter", "$", "configWriter", ")", "{", "$", "env", "=", "Environment", "::", "setUp", "(", ")", ";", "$", "instance", "=", "new", "self", "(", "[", "'processing'", "=>", "array_merge", "(", "$", "env", "->", "getConfig", "(", ")", "->", "toArray", "(", ")", ",", "[", "\"connectors\"", "=>", "[", "]", ",", "\"js_ticker\"", "=>", "[", "'enabled'", "=>", "false", ",", "'interval'", "=>", "3", "]", ",", "]", ")", "]", ",", "$", "configLocation", ")", ";", "$", "configFilePath", "=", "$", "configLocation", "->", "toString", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "self", "::", "$", "configFileName", ";", "if", "(", "file_exists", "(", "$", "configFilePath", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"Processing config already exists: \"", ".", "$", "configFilePath", ")", ";", "}", "$", "configWriter", "->", "writeNewConfigToDirectory", "(", "$", "instance", "->", "toArray", "(", ")", ",", "$", "configFilePath", ")", ";", "$", "instance", "->", "recordThat", "(", "ProcessingConfigFileWasCreated", "::", "in", "(", "$", "configLocation", ",", "self", "::", "$", "configFileName", ")", ")", ";", "return", "$", "instance", ";", "}" ]
Uses Prooph\Processing\Environment to initialize with its defaults
[ "Uses", "Prooph", "\\", "Processing", "\\", "Environment", "to", "initialize", "with", "its", "defaults" ]
835a5945dfa7be7b2cebfa6e84e757ecfd783357
https://github.com/prooph/link-app-core/blob/835a5945dfa7be7b2cebfa6e84e757ecfd783357/src/Model/ProcessingConfig.php#L80-L103
16,570
prooph/link-app-core
src/Model/ProcessingConfig.php
ProcessingConfig.configureJavascriptTicker
public function configureJavascriptTicker(array $jsTickerConfig, ConfigWriter $configWriter) { $this->assertJsTickerConfig($jsTickerConfig); $oldConfig = $this->config['processing']['js_ticker']; $this->config['processing']['js_ticker'] = $jsTickerConfig; $this->writeConfig($configWriter); $this->recordThat(JavascriptTickerWasConfigured::to($jsTickerConfig, $oldConfig)); }
php
public function configureJavascriptTicker(array $jsTickerConfig, ConfigWriter $configWriter) { $this->assertJsTickerConfig($jsTickerConfig); $oldConfig = $this->config['processing']['js_ticker']; $this->config['processing']['js_ticker'] = $jsTickerConfig; $this->writeConfig($configWriter); $this->recordThat(JavascriptTickerWasConfigured::to($jsTickerConfig, $oldConfig)); }
[ "public", "function", "configureJavascriptTicker", "(", "array", "$", "jsTickerConfig", ",", "ConfigWriter", "$", "configWriter", ")", "{", "$", "this", "->", "assertJsTickerConfig", "(", "$", "jsTickerConfig", ")", ";", "$", "oldConfig", "=", "$", "this", "->", "config", "[", "'processing'", "]", "[", "'js_ticker'", "]", ";", "$", "this", "->", "config", "[", "'processing'", "]", "[", "'js_ticker'", "]", "=", "$", "jsTickerConfig", ";", "$", "this", "->", "writeConfig", "(", "$", "configWriter", ")", ";", "$", "this", "->", "recordThat", "(", "JavascriptTickerWasConfigured", "::", "to", "(", "$", "jsTickerConfig", ",", "$", "oldConfig", ")", ")", ";", "}" ]
Configure the javascript ticker @param array $jsTickerConfig @param ConfigWriter $configWriter
[ "Configure", "the", "javascript", "ticker" ]
835a5945dfa7be7b2cebfa6e84e757ecfd783357
https://github.com/prooph/link-app-core/blob/835a5945dfa7be7b2cebfa6e84e757ecfd783357/src/Model/ProcessingConfig.php#L327-L336
16,571
prooph/link-app-core
src/Model/ProcessingConfig.php
ProcessingConfig.writeConfig
private function writeConfig(ConfigWriter $configWriter) { $configWriter->replaceConfigInDirectory( $this->toArray(), $this->configLocation->toString() . DIRECTORY_SEPARATOR . self::$configFileName ); }
php
private function writeConfig(ConfigWriter $configWriter) { $configWriter->replaceConfigInDirectory( $this->toArray(), $this->configLocation->toString() . DIRECTORY_SEPARATOR . self::$configFileName ); }
[ "private", "function", "writeConfig", "(", "ConfigWriter", "$", "configWriter", ")", "{", "$", "configWriter", "->", "replaceConfigInDirectory", "(", "$", "this", "->", "toArray", "(", ")", ",", "$", "this", "->", "configLocation", "->", "toString", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "self", "::", "$", "configFileName", ")", ";", "}" ]
Write config to file with the help of a config writer @param ConfigWriter $configWriter
[ "Write", "config", "to", "file", "with", "the", "help", "of", "a", "config", "writer" ]
835a5945dfa7be7b2cebfa6e84e757ecfd783357
https://github.com/prooph/link-app-core/blob/835a5945dfa7be7b2cebfa6e84e757ecfd783357/src/Model/ProcessingConfig.php#L585-L591
16,572
syhol/mrcolor
src/SyHolloway/MrColor/Format/Hsl.php
Hsl.hueToRgb
private function hueToRgb($v1, $v2, $vH) { if ($vH < 0) { $vH += 1; } if ($vH > 1) { $vH -= 1; } if ((6 * $vH) < 1) { return ($v1 + ($v2 - $v1) * 6 * $vH); } if ((2 * $vH) < 1) { return $v2; } if ((3 * $vH) < 2) { return ($v1 + ($v2-$v1) * ( (2/3)-$vH ) * 6); } return $v1; }
php
private function hueToRgb($v1, $v2, $vH) { if ($vH < 0) { $vH += 1; } if ($vH > 1) { $vH -= 1; } if ((6 * $vH) < 1) { return ($v1 + ($v2 - $v1) * 6 * $vH); } if ((2 * $vH) < 1) { return $v2; } if ((3 * $vH) < 2) { return ($v1 + ($v2-$v1) * ( (2/3)-$vH ) * 6); } return $v1; }
[ "private", "function", "hueToRgb", "(", "$", "v1", ",", "$", "v2", ",", "$", "vH", ")", "{", "if", "(", "$", "vH", "<", "0", ")", "{", "$", "vH", "+=", "1", ";", "}", "if", "(", "$", "vH", ">", "1", ")", "{", "$", "vH", "-=", "1", ";", "}", "if", "(", "(", "6", "*", "$", "vH", ")", "<", "1", ")", "{", "return", "(", "$", "v1", "+", "(", "$", "v2", "-", "$", "v1", ")", "*", "6", "*", "$", "vH", ")", ";", "}", "if", "(", "(", "2", "*", "$", "vH", ")", "<", "1", ")", "{", "return", "$", "v2", ";", "}", "if", "(", "(", "3", "*", "$", "vH", ")", "<", "2", ")", "{", "return", "(", "$", "v1", "+", "(", "$", "v2", "-", "$", "v1", ")", "*", "(", "(", "2", "/", "3", ")", "-", "$", "vH", ")", "*", "6", ")", ";", "}", "return", "$", "v1", ";", "}" ]
Given a Hue, returns corresponding RGB value @param float $v1 @param float $v2 @param float $vH @return float
[ "Given", "a", "Hue", "returns", "corresponding", "RGB", "value" ]
b0cfef8fa3dc52940ff6cb78d19a4fac9e02ef4d
https://github.com/syhol/mrcolor/blob/b0cfef8fa3dc52940ff6cb78d19a4fac9e02ef4d/src/SyHolloway/MrColor/Format/Hsl.php#L134-L157
16,573
EcomDev/magento-psr6-bridge
src/Model/CacheItemPool.php
CacheItemPool.prepareKey
private function prepareKey($key) { if (!preg_match('/^[a-zA-Z0-9_-]+$/', $key)) { throw new InvalidArgumentException($key); } return $this->keyPrefix . strtr($key, '-', '_'); }
php
private function prepareKey($key) { if (!preg_match('/^[a-zA-Z0-9_-]+$/', $key)) { throw new InvalidArgumentException($key); } return $this->keyPrefix . strtr($key, '-', '_'); }
[ "private", "function", "prepareKey", "(", "$", "key", ")", "{", "if", "(", "!", "preg_match", "(", "'/^[a-zA-Z0-9_-]+$/'", ",", "$", "key", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "$", "key", ")", ";", "}", "return", "$", "this", "->", "keyPrefix", ".", "strtr", "(", "$", "key", ",", "'-'", ",", "'_'", ")", ";", "}" ]
Prepares a key for cache storage @param string $key @return string @throws InvalidArgumentException
[ "Prepares", "a", "key", "for", "cache", "storage" ]
405c5b455f239fe8dc1b710df5fe9438f09d4715
https://github.com/EcomDev/magento-psr6-bridge/blob/405c5b455f239fe8dc1b710df5fe9438f09d4715/src/Model/CacheItemPool.php#L310-L317
16,574
FrenchFrogs/framework
src/Panel/Panel/Panel.php
Panel.addSelectRemote
public function addSelectRemote($name, $placeholder, $data_url, $action_url, $length = 3 ) { $e = new Action\SelectRemote($name, $placeholder, $data_url, $action_url, $length); $this->addAction($e); return $e; }
php
public function addSelectRemote($name, $placeholder, $data_url, $action_url, $length = 3 ) { $e = new Action\SelectRemote($name, $placeholder, $data_url, $action_url, $length); $this->addAction($e); return $e; }
[ "public", "function", "addSelectRemote", "(", "$", "name", ",", "$", "placeholder", ",", "$", "data_url", ",", "$", "action_url", ",", "$", "length", "=", "3", ")", "{", "$", "e", "=", "new", "Action", "\\", "SelectRemote", "(", "$", "name", ",", "$", "placeholder", ",", "$", "data_url", ",", "$", "action_url", ",", "$", "length", ")", ";", "$", "this", "->", "addAction", "(", "$", "e", ")", ";", "return", "$", "e", ";", "}" ]
Add select remote @param $name @param $placeholder @param $data_url @param $action_url @param int $length @return \FrenchFrogs\Panel\Action\SelectRemote
[ "Add", "select", "remote" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Panel/Panel/Panel.php#L207-L212
16,575
crossjoin/Css
src/Crossjoin/Css/Format/Rule/AtFontFace/FontFaceDeclaration.php
FontFaceDeclaration.checkProperty
public function checkProperty(&$property) { if (parent::checkProperty($property)) { if (preg_match( '/^(?:src|unicode-range|font-(?:family|variant|feature-settings|stretch|weight|style))$/D', $property)) { return true; } else { $this->setIsValid(false); $this->addValidationError("Invalid property '$property' for @font-face declaration."); } } return false; }
php
public function checkProperty(&$property) { if (parent::checkProperty($property)) { if (preg_match( '/^(?:src|unicode-range|font-(?:family|variant|feature-settings|stretch|weight|style))$/D', $property)) { return true; } else { $this->setIsValid(false); $this->addValidationError("Invalid property '$property' for @font-face declaration."); } } return false; }
[ "public", "function", "checkProperty", "(", "&", "$", "property", ")", "{", "if", "(", "parent", "::", "checkProperty", "(", "$", "property", ")", ")", "{", "if", "(", "preg_match", "(", "'/^(?:src|unicode-range|font-(?:family|variant|feature-settings|stretch|weight|style))$/D'", ",", "$", "property", ")", ")", "{", "return", "true", ";", "}", "else", "{", "$", "this", "->", "setIsValid", "(", "false", ")", ";", "$", "this", "->", "addValidationError", "(", "\"Invalid property '$property' for @font-face declaration.\"", ")", ";", "}", "}", "return", "false", ";", "}" ]
Checks the declaration property. @param string $property @return bool
[ "Checks", "the", "declaration", "property", "." ]
7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3
https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/AtFontFace/FontFaceDeclaration.php#L15-L29
16,576
drunomics/service-utils
src/Core/Render/MainContent/AjaxRendererTrait.php
AjaxRendererTrait.getAjaxRenderer
public function getAjaxRenderer() { if (empty($this->AjaxRenderer)) { $this->AjaxRenderer = \Drupal::service('main_content_renderer.ajax'); } return $this->AjaxRenderer; }
php
public function getAjaxRenderer() { if (empty($this->AjaxRenderer)) { $this->AjaxRenderer = \Drupal::service('main_content_renderer.ajax'); } return $this->AjaxRenderer; }
[ "public", "function", "getAjaxRenderer", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "AjaxRenderer", ")", ")", "{", "$", "this", "->", "AjaxRenderer", "=", "\\", "Drupal", "::", "service", "(", "'main_content_renderer.ajax'", ")", ";", "}", "return", "$", "this", "->", "AjaxRenderer", ";", "}" ]
Gets the ajax renderer. @return \Drupal\Core\Render\MainContent\MainContentRendererInterface The ajax renderer.
[ "Gets", "the", "ajax", "renderer", "." ]
56761750043132365ef4ae5d9e0cf4263459328f
https://github.com/drunomics/service-utils/blob/56761750043132365ef4ae5d9e0cf4263459328f/src/Core/Render/MainContent/AjaxRendererTrait.php#L38-L43
16,577
constant-null/backstubber
src/Utility/Formatter.php
Formatter.isArrayMultiline
protected static function isArrayMultiline($array) { if (empty($array)) return false; switch (self::getArrayMode()) { case self::ARR_MODE_SINGLELINE: $isMultiline = false; break; case self::ARR_MODE_MULTILINE: $isMultiline = true; break; default: // for ARR_MODE_AUTO $isMultiline = Arr::isAssoc($array) ? true : false; return $isMultiline; } return $isMultiline; }
php
protected static function isArrayMultiline($array) { if (empty($array)) return false; switch (self::getArrayMode()) { case self::ARR_MODE_SINGLELINE: $isMultiline = false; break; case self::ARR_MODE_MULTILINE: $isMultiline = true; break; default: // for ARR_MODE_AUTO $isMultiline = Arr::isAssoc($array) ? true : false; return $isMultiline; } return $isMultiline; }
[ "protected", "static", "function", "isArrayMultiline", "(", "$", "array", ")", "{", "if", "(", "empty", "(", "$", "array", ")", ")", "return", "false", ";", "switch", "(", "self", "::", "getArrayMode", "(", ")", ")", "{", "case", "self", "::", "ARR_MODE_SINGLELINE", ":", "$", "isMultiline", "=", "false", ";", "break", ";", "case", "self", "::", "ARR_MODE_MULTILINE", ":", "$", "isMultiline", "=", "true", ";", "break", ";", "default", ":", "// for ARR_MODE_AUTO", "$", "isMultiline", "=", "Arr", "::", "isAssoc", "(", "$", "array", ")", "?", "true", ":", "false", ";", "return", "$", "isMultiline", ";", "}", "return", "$", "isMultiline", ";", "}" ]
Determines if array should be formatted as a multiline one or not @param array $array @return bool
[ "Determines", "if", "array", "should", "be", "formatted", "as", "a", "multiline", "one", "or", "not" ]
1e7ee66091bae4e6b709642467609a8566dae479
https://github.com/constant-null/backstubber/blob/1e7ee66091bae4e6b709642467609a8566dae479/src/Utility/Formatter.php#L28-L44
16,578
constant-null/backstubber
src/Utility/Formatter.php
Formatter.prepareArrayLines
protected static function prepareArrayLines(array $array) { $isAssoc = Arr::isAssoc($array); array_walk($array, function (&$value, $index, $withIndexes = false) { if (is_array($value)) { $value = self::formatArray($value); } else { $value = self::formatScalar($value); } if ($withIndexes) { $value = self::formatScalar($index) . ' => ' . $value; } }, $isAssoc); return $array; }
php
protected static function prepareArrayLines(array $array) { $isAssoc = Arr::isAssoc($array); array_walk($array, function (&$value, $index, $withIndexes = false) { if (is_array($value)) { $value = self::formatArray($value); } else { $value = self::formatScalar($value); } if ($withIndexes) { $value = self::formatScalar($index) . ' => ' . $value; } }, $isAssoc); return $array; }
[ "protected", "static", "function", "prepareArrayLines", "(", "array", "$", "array", ")", "{", "$", "isAssoc", "=", "Arr", "::", "isAssoc", "(", "$", "array", ")", ";", "array_walk", "(", "$", "array", ",", "function", "(", "&", "$", "value", ",", "$", "index", ",", "$", "withIndexes", "=", "false", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "self", "::", "formatArray", "(", "$", "value", ")", ";", "}", "else", "{", "$", "value", "=", "self", "::", "formatScalar", "(", "$", "value", ")", ";", "}", "if", "(", "$", "withIndexes", ")", "{", "$", "value", "=", "self", "::", "formatScalar", "(", "$", "index", ")", ".", "' => '", ".", "$", "value", ";", "}", "}", ",", "$", "isAssoc", ")", ";", "return", "$", "array", ";", "}" ]
Prepare array elements for formatting. @param array $array @return array
[ "Prepare", "array", "elements", "for", "formatting", "." ]
1e7ee66091bae4e6b709642467609a8566dae479
https://github.com/constant-null/backstubber/blob/1e7ee66091bae4e6b709642467609a8566dae479/src/Utility/Formatter.php#L63-L80
16,579
constant-null/backstubber
src/Utility/Formatter.php
Formatter.indentLines
public static function indentLines($text, $indent, $skipFirstLine = false) { $lines = explode(PHP_EOL, $text); // (つ◕.◕)つ━☆゚.*・。゚ !$skipFirstLine || $preparedLines[] = array_shift($lines); foreach ($lines as $line) { $preparedLines[] = self::indent($indent) . rtrim($line); } return implode(PHP_EOL, $preparedLines); }
php
public static function indentLines($text, $indent, $skipFirstLine = false) { $lines = explode(PHP_EOL, $text); // (つ◕.◕)つ━☆゚.*・。゚ !$skipFirstLine || $preparedLines[] = array_shift($lines); foreach ($lines as $line) { $preparedLines[] = self::indent($indent) . rtrim($line); } return implode(PHP_EOL, $preparedLines); }
[ "public", "static", "function", "indentLines", "(", "$", "text", ",", "$", "indent", ",", "$", "skipFirstLine", "=", "false", ")", "{", "$", "lines", "=", "explode", "(", "PHP_EOL", ",", "$", "text", ")", ";", "// (つ◕.◕)つ━☆゚.*・。゚", "!", "$", "skipFirstLine", "||", "$", "preparedLines", "[", "]", "=", "array_shift", "(", "$", "lines", ")", ";", "foreach", "(", "$", "lines", "as", "$", "line", ")", "{", "$", "preparedLines", "[", "]", "=", "self", "::", "indent", "(", "$", "indent", ")", ".", "rtrim", "(", "$", "line", ")", ";", "}", "return", "implode", "(", "PHP_EOL", ",", "$", "preparedLines", ")", ";", "}" ]
Add indents to multiline text @param string $text @param integer $indent indent in spaces @param bool $skipFirstLine = false not apply indent to the first line of text @return array
[ "Add", "indents", "to", "multiline", "text" ]
1e7ee66091bae4e6b709642467609a8566dae479
https://github.com/constant-null/backstubber/blob/1e7ee66091bae4e6b709642467609a8566dae479/src/Utility/Formatter.php#L90-L102
16,580
constant-null/backstubber
src/Utility/Formatter.php
Formatter.formatArray
public static function formatArray(array $array, $braces = true) { $isMultiline = self::isArrayMultiline($array); $array = self::prepareArrayLines($array); $eol = $isMultiline ? PHP_EOL : ''; $output = implode($array, ', ' . $eol); if ($isMultiline) { // apply base indent to array elements $output = self::indentLines($output, self::$tabSize); } if ($braces) { $output = implode(['[', $output, ']'], $eol); } else { $output = $eol . $output . $eol; } return $output; }
php
public static function formatArray(array $array, $braces = true) { $isMultiline = self::isArrayMultiline($array); $array = self::prepareArrayLines($array); $eol = $isMultiline ? PHP_EOL : ''; $output = implode($array, ', ' . $eol); if ($isMultiline) { // apply base indent to array elements $output = self::indentLines($output, self::$tabSize); } if ($braces) { $output = implode(['[', $output, ']'], $eol); } else { $output = $eol . $output . $eol; } return $output; }
[ "public", "static", "function", "formatArray", "(", "array", "$", "array", ",", "$", "braces", "=", "true", ")", "{", "$", "isMultiline", "=", "self", "::", "isArrayMultiline", "(", "$", "array", ")", ";", "$", "array", "=", "self", "::", "prepareArrayLines", "(", "$", "array", ")", ";", "$", "eol", "=", "$", "isMultiline", "?", "PHP_EOL", ":", "''", ";", "$", "output", "=", "implode", "(", "$", "array", ",", "', '", ".", "$", "eol", ")", ";", "if", "(", "$", "isMultiline", ")", "{", "// apply base indent to array elements", "$", "output", "=", "self", "::", "indentLines", "(", "$", "output", ",", "self", "::", "$", "tabSize", ")", ";", "}", "if", "(", "$", "braces", ")", "{", "$", "output", "=", "implode", "(", "[", "'['", ",", "$", "output", ",", "']'", "]", ",", "$", "eol", ")", ";", "}", "else", "{", "$", "output", "=", "$", "eol", ".", "$", "output", ".", "$", "eol", ";", "}", "return", "$", "output", ";", "}" ]
Return text representation of array @param array $array input array @param bool $braces add array braces to output @return string
[ "Return", "text", "representation", "of", "array" ]
1e7ee66091bae4e6b709642467609a8566dae479
https://github.com/constant-null/backstubber/blob/1e7ee66091bae4e6b709642467609a8566dae479/src/Utility/Formatter.php#L131-L153
16,581
goblindegook/Syllables
src/Exception/WP_Exception.php
WP_Exception.get_wp_error
public function get_wp_error() { return $this->wp_error ? $this->wp_error : new \WP_Error( $this->code, $this->message, $this ); }
php
public function get_wp_error() { return $this->wp_error ? $this->wp_error : new \WP_Error( $this->code, $this->message, $this ); }
[ "public", "function", "get_wp_error", "(", ")", "{", "return", "$", "this", "->", "wp_error", "?", "$", "this", "->", "wp_error", ":", "new", "\\", "WP_Error", "(", "$", "this", "->", "code", ",", "$", "this", "->", "message", ",", "$", "this", ")", ";", "}" ]
Obtain the exception's `\WP_Error` object. @return \WP_Error WordPress error.
[ "Obtain", "the", "exception", "s", "\\", "WP_Error", "object", "." ]
1a98cd15e37595a85b242242f88fee38c4e36acc
https://github.com/goblindegook/Syllables/blob/1a98cd15e37595a85b242242f88fee38c4e36acc/src/Exception/WP_Exception.php#L80-L82
16,582
jan-dolata/crude-crud
src/Engine/Helpers/CrudeSpecialFiles.php
CrudeSpecialFiles.upload
public function upload($file, $key) { if (! $file || ! $this->isValidKey($key)) return; $fileName = $file->getClientOriginalName(); $pathinfo = pathinfo($fileName); $this->deleteStored($key); Storage::putFileAs($this->getStoragePath(), $file, $key . '.' . $pathinfo['extension']); }
php
public function upload($file, $key) { if (! $file || ! $this->isValidKey($key)) return; $fileName = $file->getClientOriginalName(); $pathinfo = pathinfo($fileName); $this->deleteStored($key); Storage::putFileAs($this->getStoragePath(), $file, $key . '.' . $pathinfo['extension']); }
[ "public", "function", "upload", "(", "$", "file", ",", "$", "key", ")", "{", "if", "(", "!", "$", "file", "||", "!", "$", "this", "->", "isValidKey", "(", "$", "key", ")", ")", "return", ";", "$", "fileName", "=", "$", "file", "->", "getClientOriginalName", "(", ")", ";", "$", "pathinfo", "=", "pathinfo", "(", "$", "fileName", ")", ";", "$", "this", "->", "deleteStored", "(", "$", "key", ")", ";", "Storage", "::", "putFileAs", "(", "$", "this", "->", "getStoragePath", "(", ")", ",", "$", "file", ",", "$", "key", ".", "'.'", ".", "$", "pathinfo", "[", "'extension'", "]", ")", ";", "}" ]
Upload file if exist and key is correct @param File $file @param string $key
[ "Upload", "file", "if", "exist", "and", "key", "is", "correct" ]
9129ea08278835cf5cecfd46a90369226ae6bdd7
https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/Helpers/CrudeSpecialFiles.php#L53-L64
16,583
jan-dolata/crude-crud
src/Engine/Helpers/CrudeSpecialFiles.php
CrudeSpecialFiles.getFileData
private function getFileData($key) { foreach ($this->getStoredList() as $filePath) { $pathinfo = pathinfo($filePath); if ($key == $pathinfo['filename']) return [ 'storedPath' => $filePath, 'path' => storage_path('app/' . $filePath), 'extension' => $pathinfo['extension'], 'size' => Storage::size($filePath), 'lastModified' => Storage::lastModified($filePath) ]; } return false; }
php
private function getFileData($key) { foreach ($this->getStoredList() as $filePath) { $pathinfo = pathinfo($filePath); if ($key == $pathinfo['filename']) return [ 'storedPath' => $filePath, 'path' => storage_path('app/' . $filePath), 'extension' => $pathinfo['extension'], 'size' => Storage::size($filePath), 'lastModified' => Storage::lastModified($filePath) ]; } return false; }
[ "private", "function", "getFileData", "(", "$", "key", ")", "{", "foreach", "(", "$", "this", "->", "getStoredList", "(", ")", "as", "$", "filePath", ")", "{", "$", "pathinfo", "=", "pathinfo", "(", "$", "filePath", ")", ";", "if", "(", "$", "key", "==", "$", "pathinfo", "[", "'filename'", "]", ")", "return", "[", "'storedPath'", "=>", "$", "filePath", ",", "'path'", "=>", "storage_path", "(", "'app/'", ".", "$", "filePath", ")", ",", "'extension'", "=>", "$", "pathinfo", "[", "'extension'", "]", ",", "'size'", "=>", "Storage", "::", "size", "(", "$", "filePath", ")", ",", "'lastModified'", "=>", "Storage", "::", "lastModified", "(", "$", "filePath", ")", "]", ";", "}", "return", "false", ";", "}" ]
Get file path and extension or null if file is not stored @param string $key @return array|false
[ "Get", "file", "path", "and", "extension", "or", "null", "if", "file", "is", "not", "stored" ]
9129ea08278835cf5cecfd46a90369226ae6bdd7
https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/Helpers/CrudeSpecialFiles.php#L76-L93
16,584
Srokap/code_review
classes/CodeReview/Autoloader.php
Autoloader.registerDirectory
private function registerDirectory($basePath, $prefix = '') { $basePath = str_replace('\\', '/', $basePath); $basePath = rtrim($basePath, '/') . '/'; $prefix = ($prefix ? $prefix . '_' : '' ); $files = scandir($basePath); foreach ($files as $file) { if ($file[0] == '.') { continue; } $path = $basePath . $file; if (is_dir($path)) { $this->registerDirectory($path, $prefix . pathinfo($path, PATHINFO_FILENAME)); } elseif (strtolower(pathinfo($path, PATHINFO_EXTENSION)) == 'php') { $name = $prefix . pathinfo($path, PATHINFO_FILENAME); $this->classMap[$name] = $path; $name = str_replace('_', '\\', $name); // register again in case it was namespaced $this->classMap[$name] = $path; } } }
php
private function registerDirectory($basePath, $prefix = '') { $basePath = str_replace('\\', '/', $basePath); $basePath = rtrim($basePath, '/') . '/'; $prefix = ($prefix ? $prefix . '_' : '' ); $files = scandir($basePath); foreach ($files as $file) { if ($file[0] == '.') { continue; } $path = $basePath . $file; if (is_dir($path)) { $this->registerDirectory($path, $prefix . pathinfo($path, PATHINFO_FILENAME)); } elseif (strtolower(pathinfo($path, PATHINFO_EXTENSION)) == 'php') { $name = $prefix . pathinfo($path, PATHINFO_FILENAME); $this->classMap[$name] = $path; $name = str_replace('_', '\\', $name); // register again in case it was namespaced $this->classMap[$name] = $path; } } }
[ "private", "function", "registerDirectory", "(", "$", "basePath", ",", "$", "prefix", "=", "''", ")", "{", "$", "basePath", "=", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "$", "basePath", ")", ";", "$", "basePath", "=", "rtrim", "(", "$", "basePath", ",", "'/'", ")", ".", "'/'", ";", "$", "prefix", "=", "(", "$", "prefix", "?", "$", "prefix", ".", "'_'", ":", "''", ")", ";", "$", "files", "=", "scandir", "(", "$", "basePath", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "if", "(", "$", "file", "[", "0", "]", "==", "'.'", ")", "{", "continue", ";", "}", "$", "path", "=", "$", "basePath", ".", "$", "file", ";", "if", "(", "is_dir", "(", "$", "path", ")", ")", "{", "$", "this", "->", "registerDirectory", "(", "$", "path", ",", "$", "prefix", ".", "pathinfo", "(", "$", "path", ",", "PATHINFO_FILENAME", ")", ")", ";", "}", "elseif", "(", "strtolower", "(", "pathinfo", "(", "$", "path", ",", "PATHINFO_EXTENSION", ")", ")", "==", "'php'", ")", "{", "$", "name", "=", "$", "prefix", ".", "pathinfo", "(", "$", "path", ",", "PATHINFO_FILENAME", ")", ";", "$", "this", "->", "classMap", "[", "$", "name", "]", "=", "$", "path", ";", "$", "name", "=", "str_replace", "(", "'_'", ",", "'\\\\'", ",", "$", "name", ")", ";", "// register again in case it was namespaced", "$", "this", "->", "classMap", "[", "$", "name", "]", "=", "$", "path", ";", "}", "}", "}" ]
Not fully PSR-0 compatible, but good enough for this particular plugin @param string $basePath @param string $prefix
[ "Not", "fully", "PSR", "-", "0", "compatible", "but", "good", "enough", "for", "this", "particular", "plugin" ]
c79c619f99279cf15713b118ae19b0ef017db362
https://github.com/Srokap/code_review/blob/c79c619f99279cf15713b118ae19b0ef017db362/classes/CodeReview/Autoloader.php#L24-L43
16,585
sulu/SuluSalesShippingBundle
src/Sulu/Bundle/Sales/OrderBundle/Controller/TemplateController.php
TemplateController.getSystemUserArray
public function getSystemUserArray() { $repo = $this->get('sulu_security.user_repository'); $users = $repo->getUserInSystem(); $contacts = []; foreach ($users as $user) { $contact = $user->getContact(); $contacts[] = array( 'id' => $contact->getId(), 'fullName' => $contact->getFullName() ); } return $contacts; }
php
public function getSystemUserArray() { $repo = $this->get('sulu_security.user_repository'); $users = $repo->getUserInSystem(); $contacts = []; foreach ($users as $user) { $contact = $user->getContact(); $contacts[] = array( 'id' => $contact->getId(), 'fullName' => $contact->getFullName() ); } return $contacts; }
[ "public", "function", "getSystemUserArray", "(", ")", "{", "$", "repo", "=", "$", "this", "->", "get", "(", "'sulu_security.user_repository'", ")", ";", "$", "users", "=", "$", "repo", "->", "getUserInSystem", "(", ")", ";", "$", "contacts", "=", "[", "]", ";", "foreach", "(", "$", "users", "as", "$", "user", ")", "{", "$", "contact", "=", "$", "user", "->", "getContact", "(", ")", ";", "$", "contacts", "[", "]", "=", "array", "(", "'id'", "=>", "$", "contact", "->", "getId", "(", ")", ",", "'fullName'", "=>", "$", "contact", "->", "getFullName", "(", ")", ")", ";", "}", "return", "$", "contacts", ";", "}" ]
returns all sulu system users @return array
[ "returns", "all", "sulu", "system", "users" ]
0d39de262d58579e5679db99a77dbf717d600b5e
https://github.com/sulu/SuluSalesShippingBundle/blob/0d39de262d58579e5679db99a77dbf717d600b5e/src/Sulu/Bundle/Sales/OrderBundle/Controller/TemplateController.php#L51-L65
16,586
sulu/SuluSalesShippingBundle
src/Sulu/Bundle/Sales/OrderBundle/Controller/TemplateController.php
TemplateController.getOrderStatus
public function getOrderStatus() { $statuses = $this->getDoctrine()->getRepository(self::$orderStatusEntityName)->findAll(); $locale = $this->getUser()->getLocale(); $statusArray = []; foreach ($statuses as $statusEntity) { $status = new OrderStatus($statusEntity, $locale); $statusArray[] = array( 'id' => $status->getId(), 'status' => $status->getStatus() ); } return $statusArray; }
php
public function getOrderStatus() { $statuses = $this->getDoctrine()->getRepository(self::$orderStatusEntityName)->findAll(); $locale = $this->getUser()->getLocale(); $statusArray = []; foreach ($statuses as $statusEntity) { $status = new OrderStatus($statusEntity, $locale); $statusArray[] = array( 'id' => $status->getId(), 'status' => $status->getStatus() ); } return $statusArray; }
[ "public", "function", "getOrderStatus", "(", ")", "{", "$", "statuses", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getRepository", "(", "self", "::", "$", "orderStatusEntityName", ")", "->", "findAll", "(", ")", ";", "$", "locale", "=", "$", "this", "->", "getUser", "(", ")", "->", "getLocale", "(", ")", ";", "$", "statusArray", "=", "[", "]", ";", "foreach", "(", "$", "statuses", "as", "$", "statusEntity", ")", "{", "$", "status", "=", "new", "OrderStatus", "(", "$", "statusEntity", ",", "$", "locale", ")", ";", "$", "statusArray", "[", "]", "=", "array", "(", "'id'", "=>", "$", "status", "->", "getId", "(", ")", ",", "'status'", "=>", "$", "status", "->", "getStatus", "(", ")", ")", ";", "}", "return", "$", "statusArray", ";", "}" ]
returns array of order statuses @return array
[ "returns", "array", "of", "order", "statuses" ]
0d39de262d58579e5679db99a77dbf717d600b5e
https://github.com/sulu/SuluSalesShippingBundle/blob/0d39de262d58579e5679db99a77dbf717d600b5e/src/Sulu/Bundle/Sales/OrderBundle/Controller/TemplateController.php#L90-L104
16,587
chriswoodford/foursquare-php
lib/TheTwelve/Foursquare/HttpClient/CurlHttpClient.php
CurlHttpClient.initCurlHandler
protected function initCurlHandler($uri) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $uri); curl_setopt($ch, CURLOPT_USERAGENT, 'twelvelabs/foursquare client'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $this->verifyHost); if ($this->verifyPeer === false) { curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); } else { // @see http://curl.haxx.se/docs/caextract.html if (!file_exists($this->certificatePath)) { throw new \RuntimeException('cacert.pem file not found'); } curl_setopt ($ch, CURLOPT_CAINFO, $this->certificatePath); } return $ch; }
php
protected function initCurlHandler($uri) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $uri); curl_setopt($ch, CURLOPT_USERAGENT, 'twelvelabs/foursquare client'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $this->verifyHost); if ($this->verifyPeer === false) { curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); } else { // @see http://curl.haxx.se/docs/caextract.html if (!file_exists($this->certificatePath)) { throw new \RuntimeException('cacert.pem file not found'); } curl_setopt ($ch, CURLOPT_CAINFO, $this->certificatePath); } return $ch; }
[ "protected", "function", "initCurlHandler", "(", "$", "uri", ")", "{", "$", "ch", "=", "curl_init", "(", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_URL", ",", "$", "uri", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_USERAGENT", ",", "'twelvelabs/foursquare client'", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_SSL_VERIFYHOST", ",", "$", "this", "->", "verifyHost", ")", ";", "if", "(", "$", "this", "->", "verifyPeer", "===", "false", ")", "{", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_SSL_VERIFYPEER", ",", "false", ")", ";", "}", "else", "{", "// @see http://curl.haxx.se/docs/caextract.html", "if", "(", "!", "file_exists", "(", "$", "this", "->", "certificatePath", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'cacert.pem file not found'", ")", ";", "}", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_CAINFO", ",", "$", "this", "->", "certificatePath", ")", ";", "}", "return", "$", "ch", ";", "}" ]
initialize the cURL handler @param string $uri @return resource
[ "initialize", "the", "cURL", "handler" ]
edbfcba2993a101ead8f381394742a4689aec398
https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/HttpClient/CurlHttpClient.php#L103-L128
16,588
etki/opencart-core-installer
src/Installer.php
Installer.supports
public function supports($packageType) { DebugPrinter::log( 'Checking support for package type `%s` (%s)', array($packageType, $packageType === $this->packageType ? 'y' : 'n') ); return $packageType === $this->packageType; }
php
public function supports($packageType) { DebugPrinter::log( 'Checking support for package type `%s` (%s)', array($packageType, $packageType === $this->packageType ? 'y' : 'n') ); return $packageType === $this->packageType; }
[ "public", "function", "supports", "(", "$", "packageType", ")", "{", "DebugPrinter", "::", "log", "(", "'Checking support for package type `%s` (%s)'", ",", "array", "(", "$", "packageType", ",", "$", "packageType", "===", "$", "this", "->", "packageType", "?", "'y'", ":", "'n'", ")", ")", ";", "return", "$", "packageType", "===", "$", "this", "->", "packageType", ";", "}" ]
Tells composer if this installer supports provided package type. @param string $packageType Package type name. @return bool @since 0.1.0
[ "Tells", "composer", "if", "this", "installer", "supports", "provided", "package", "type", "." ]
e651c94982afe966cd36977bbdc2ff4f7e785475
https://github.com/etki/opencart-core-installer/blob/e651c94982afe966cd36977bbdc2ff4f7e785475/src/Installer.php#L53-L60
16,589
datasift/datasift-php
lib/DataSift/StreamConsumer.php
DataSift_StreamConsumer.factory
public static function factory($user, $type, $definition, $eventHandler) { $classname = 'DataSift_StreamConsumer_' . $type; if (! class_exists($classname)) { throw new DataSift_Exception_InvalidData('Consumer type "' . $type . '" is unknown'); } return new $classname($user, $definition, $eventHandler); }
php
public static function factory($user, $type, $definition, $eventHandler) { $classname = 'DataSift_StreamConsumer_' . $type; if (! class_exists($classname)) { throw new DataSift_Exception_InvalidData('Consumer type "' . $type . '" is unknown'); } return new $classname($user, $definition, $eventHandler); }
[ "public", "static", "function", "factory", "(", "$", "user", ",", "$", "type", ",", "$", "definition", ",", "$", "eventHandler", ")", "{", "$", "classname", "=", "'DataSift_StreamConsumer_'", ".", "$", "type", ";", "if", "(", "!", "class_exists", "(", "$", "classname", ")", ")", "{", "throw", "new", "DataSift_Exception_InvalidData", "(", "'Consumer type \"'", ".", "$", "type", ".", "'\" is unknown'", ")", ";", "}", "return", "new", "$", "classname", "(", "$", "user", ",", "$", "definition", ",", "$", "eventHandler", ")", ";", "}" ]
Factory function. Creates a StreamConsumer-derived object for the given type. @param string $user Use DataSift_User object. @param string $type Use the TYPE_ constants @param mixed $definition CSDL string or a Definition object. @param string $eventHandler The object that will receive events. @return DataSift_StreamConsumer The consumer object @throws DataSift_Exception_InvalidData
[ "Factory", "function", ".", "Creates", "a", "StreamConsumer", "-", "derived", "object", "for", "the", "given", "type", "." ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/StreamConsumer.php#L82-L90
16,590
datasift/datasift-php
lib/DataSift/StreamConsumer.php
DataSift_StreamConsumer.onData
protected function onData($json) { // Decode the JSON $interaction = json_decode(trim($json), true); // If the interaction is valid, pass it to the event handler if ($interaction) { if (isset($interaction['status'])) { switch ($interaction['status']) { case 'error': case 'failure': $this->onError($interaction['message']); // Stop the consumer when an error is received $this->stop(); break; case 'warning': $this->onWarning($interaction['message']); break; default: $type = $interaction['status']; unset($interaction['status']); $this->onStatus($type, $interaction); break; } } else { // Extract the hash and the data if present $hash = false; if (isset($interaction['hash'])) { $hash = $interaction['hash']; $interaction = $interaction['data']; } // Ignore ticks and handle delete requests if (! empty($interaction['deleted'])) { $this->onDeleted($interaction, $hash); } elseif (! empty($interaction['interaction'])) { $this->onInteraction($interaction, $hash); } } } }
php
protected function onData($json) { // Decode the JSON $interaction = json_decode(trim($json), true); // If the interaction is valid, pass it to the event handler if ($interaction) { if (isset($interaction['status'])) { switch ($interaction['status']) { case 'error': case 'failure': $this->onError($interaction['message']); // Stop the consumer when an error is received $this->stop(); break; case 'warning': $this->onWarning($interaction['message']); break; default: $type = $interaction['status']; unset($interaction['status']); $this->onStatus($type, $interaction); break; } } else { // Extract the hash and the data if present $hash = false; if (isset($interaction['hash'])) { $hash = $interaction['hash']; $interaction = $interaction['data']; } // Ignore ticks and handle delete requests if (! empty($interaction['deleted'])) { $this->onDeleted($interaction, $hash); } elseif (! empty($interaction['interaction'])) { $this->onInteraction($interaction, $hash); } } } }
[ "protected", "function", "onData", "(", "$", "json", ")", "{", "// Decode the JSON", "$", "interaction", "=", "json_decode", "(", "trim", "(", "$", "json", ")", ",", "true", ")", ";", "// If the interaction is valid, pass it to the event handler", "if", "(", "$", "interaction", ")", "{", "if", "(", "isset", "(", "$", "interaction", "[", "'status'", "]", ")", ")", "{", "switch", "(", "$", "interaction", "[", "'status'", "]", ")", "{", "case", "'error'", ":", "case", "'failure'", ":", "$", "this", "->", "onError", "(", "$", "interaction", "[", "'message'", "]", ")", ";", "// Stop the consumer when an error is received", "$", "this", "->", "stop", "(", ")", ";", "break", ";", "case", "'warning'", ":", "$", "this", "->", "onWarning", "(", "$", "interaction", "[", "'message'", "]", ")", ";", "break", ";", "default", ":", "$", "type", "=", "$", "interaction", "[", "'status'", "]", ";", "unset", "(", "$", "interaction", "[", "'status'", "]", ")", ";", "$", "this", "->", "onStatus", "(", "$", "type", ",", "$", "interaction", ")", ";", "break", ";", "}", "}", "else", "{", "// Extract the hash and the data if present", "$", "hash", "=", "false", ";", "if", "(", "isset", "(", "$", "interaction", "[", "'hash'", "]", ")", ")", "{", "$", "hash", "=", "$", "interaction", "[", "'hash'", "]", ";", "$", "interaction", "=", "$", "interaction", "[", "'data'", "]", ";", "}", "// Ignore ticks and handle delete requests", "if", "(", "!", "empty", "(", "$", "interaction", "[", "'deleted'", "]", ")", ")", "{", "$", "this", "->", "onDeleted", "(", "$", "interaction", ",", "$", "hash", ")", ";", "}", "elseif", "(", "!", "empty", "(", "$", "interaction", "[", "'interaction'", "]", ")", ")", "{", "$", "this", "->", "onInteraction", "(", "$", "interaction", ",", "$", "hash", ")", ";", "}", "}", "}", "}" ]
This is called when a complete JSON item is received. @param $json The JSON data. @return void
[ "This", "is", "called", "when", "a", "complete", "JSON", "item", "is", "received", "." ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/StreamConsumer.php#L159-L198
16,591
datasift/datasift-php
lib/DataSift/StreamConsumer.php
DataSift_StreamConsumer.onInteraction
protected function onInteraction($interaction, $hash = false) { $this->_eventHandler->onInteraction($this, $interaction, $hash); }
php
protected function onInteraction($interaction, $hash = false) { $this->_eventHandler->onInteraction($this, $interaction, $hash); }
[ "protected", "function", "onInteraction", "(", "$", "interaction", ",", "$", "hash", "=", "false", ")", "{", "$", "this", "->", "_eventHandler", "->", "onInteraction", "(", "$", "this", ",", "$", "interaction", ",", "$", "hash", ")", ";", "}" ]
This is called for each interaction received from the stream and must be implemented in extending classes. @param array $interaction The interaction data structure @param bool $hash @return void
[ "This", "is", "called", "for", "each", "interaction", "received", "from", "the", "stream", "and", "must", "be", "implemented", "in", "extending", "classes", "." ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/StreamConsumer.php#L219-L222
16,592
datasift/datasift-php
lib/DataSift/StreamConsumer.php
DataSift_StreamConsumer.onDeleted
protected function onDeleted($interaction, $hash = false) { $this->_eventHandler->onDeleted($this, $interaction, $hash); }
php
protected function onDeleted($interaction, $hash = false) { $this->_eventHandler->onDeleted($this, $interaction, $hash); }
[ "protected", "function", "onDeleted", "(", "$", "interaction", ",", "$", "hash", "=", "false", ")", "{", "$", "this", "->", "_eventHandler", "->", "onDeleted", "(", "$", "this", ",", "$", "interaction", ",", "$", "hash", ")", ";", "}" ]
This is called for each DELETE request received from the stream and must be implemented in extending classes. @param array $interaction The interaction data structure @param string $hash The stream hash. @return void
[ "This", "is", "called", "for", "each", "DELETE", "request", "received", "from", "the", "stream", "and", "must", "be", "implemented", "in", "extending", "classes", "." ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/StreamConsumer.php#L233-L236
16,593
datasift/datasift-php
lib/DataSift/StreamConsumer.php
DataSift_StreamConsumer.consume
public function consume($auto_reconnect = true) { $this->_auto_reconnect = $auto_reconnect; // Start consuming $this->_state = self::STATE_STARTING; $this->onStart(); }
php
public function consume($auto_reconnect = true) { $this->_auto_reconnect = $auto_reconnect; // Start consuming $this->_state = self::STATE_STARTING; $this->onStart(); }
[ "public", "function", "consume", "(", "$", "auto_reconnect", "=", "true", ")", "{", "$", "this", "->", "_auto_reconnect", "=", "$", "auto_reconnect", ";", "// Start consuming", "$", "this", "->", "_state", "=", "self", "::", "STATE_STARTING", ";", "$", "this", "->", "onStart", "(", ")", ";", "}" ]
Once an instance of a StreamConsumer is ready for use, call this to start consuming. Extending classes should implement onStart to handle actually starting. @param boolean $auto_reconnect Whether to reconnect automatically @return void
[ "Once", "an", "instance", "of", "a", "StreamConsumer", "is", "ready", "for", "use", "call", "this", "to", "start", "consuming", ".", "Extending", "classes", "should", "implement", "onStart", "to", "handle", "actually", "starting", "." ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/StreamConsumer.php#L308-L315
16,594
datasift/datasift-php
lib/DataSift/StreamConsumer.php
DataSift_StreamConsumer.onStop
protected function onStop($reason = '') { //var_dump(debug_backtrace()); if ($this->_state != self::STATE_STOPPING and $reason == '') { $reason = 'Unexpected'; } $this->_state = self::STATE_STOPPED; $this->onStopped($reason); }
php
protected function onStop($reason = '') { //var_dump(debug_backtrace()); if ($this->_state != self::STATE_STOPPING and $reason == '') { $reason = 'Unexpected'; } $this->_state = self::STATE_STOPPED; $this->onStopped($reason); }
[ "protected", "function", "onStop", "(", "$", "reason", "=", "''", ")", "{", "//var_dump(debug_backtrace());", "if", "(", "$", "this", "->", "_state", "!=", "self", "::", "STATE_STOPPING", "and", "$", "reason", "==", "''", ")", "{", "$", "reason", "=", "'Unexpected'", ";", "}", "$", "this", "->", "_state", "=", "self", "::", "STATE_STOPPED", ";", "$", "this", "->", "onStopped", "(", "$", "reason", ")", ";", "}" ]
Default implementation of onStop. It's unlikely that this method will ever be used in isolation, but rather it should be called as the final step in the extending class's implementation. @param string $reason Reason why the stream was stopped @return void @throws DataSift_Exception_InvalidData
[ "Default", "implementation", "of", "onStop", ".", "It", "s", "unlikely", "that", "this", "method", "will", "ever", "be", "used", "in", "isolation", "but", "rather", "it", "should", "be", "called", "as", "the", "final", "step", "in", "the", "extending", "class", "s", "implementation", "." ]
35282461ad3e54880e5940bb5afce26c75dc4bb9
https://github.com/datasift/datasift-php/blob/35282461ad3e54880e5940bb5afce26c75dc4bb9/lib/DataSift/StreamConsumer.php#L352-L361
16,595
kiwiz/ecl
src/ArrayUnion.php
ArrayUnion.getKeys
public function getKeys() { $keys = []; foreach($this->arrays as $array) { $keys = array_merge($keys, $array instanceof \ArrayAccess ? $array->getKeys():array_keys($array)); } return array_unique($keys); }
php
public function getKeys() { $keys = []; foreach($this->arrays as $array) { $keys = array_merge($keys, $array instanceof \ArrayAccess ? $array->getKeys():array_keys($array)); } return array_unique($keys); }
[ "public", "function", "getKeys", "(", ")", "{", "$", "keys", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "arrays", "as", "$", "array", ")", "{", "$", "keys", "=", "array_merge", "(", "$", "keys", ",", "$", "array", "instanceof", "\\", "ArrayAccess", "?", "$", "array", "->", "getKeys", "(", ")", ":", "array_keys", "(", "$", "array", ")", ")", ";", "}", "return", "array_unique", "(", "$", "keys", ")", ";", "}" ]
Get a list of all defined keys. @return string[] Keys.
[ "Get", "a", "list", "of", "all", "defined", "keys", "." ]
6536dd2a4c1905a08cf718bdbef56a22f0e9b488
https://github.com/kiwiz/ecl/blob/6536dd2a4c1905a08cf718bdbef56a22f0e9b488/src/ArrayUnion.php#L25-L31
16,596
phramework/validate
src/NumberValidator.php
NumberValidator.validateNumber
protected function validateNumber($value) { $return = new ValidateResult($value, false); if (is_string($value)) { //Replace comma with dot $value = str_replace(',', '.', $value); } //Apply all rules if (!is_numeric($value) || filter_var($value, FILTER_VALIDATE_FLOAT) === false) { //error $return->errorObject = new IncorrectParametersException([ [ 'type' => static::getType(), 'failure' => 'type' ] ]); } elseif ($this->maximum !== null && ($value > $this->maximum || ($this->exclusiveMaximum === true && $value >= $this->maximum) ) ) { //error $return->errorObject = new IncorrectParametersException([ [ 'type' => static::getType(), 'failure' => 'maximum' ] ]); } elseif ($this->minimum !== null && ($value < $this->minimum || ($this->exclusiveMinimum === true && $value <= $this->minimum) ) ) { //error $return->errorObject = new IncorrectParametersException([ [ 'type' => static::getType(), 'failure' => 'minimum' ] ]); } elseif ($this->multipleOf !== null && fmod((float)$value, (float)$this->multipleOf) != 0 ) { //error $return->errorObject = new IncorrectParametersException([ [ 'type' => static::getType(), 'failure' => 'multipleOf' ] ]); } else { $return->errorObject = null; //Set status to success $return->status = true; //Type cast $return->value = $this->cast($value); } return $return; }
php
protected function validateNumber($value) { $return = new ValidateResult($value, false); if (is_string($value)) { //Replace comma with dot $value = str_replace(',', '.', $value); } //Apply all rules if (!is_numeric($value) || filter_var($value, FILTER_VALIDATE_FLOAT) === false) { //error $return->errorObject = new IncorrectParametersException([ [ 'type' => static::getType(), 'failure' => 'type' ] ]); } elseif ($this->maximum !== null && ($value > $this->maximum || ($this->exclusiveMaximum === true && $value >= $this->maximum) ) ) { //error $return->errorObject = new IncorrectParametersException([ [ 'type' => static::getType(), 'failure' => 'maximum' ] ]); } elseif ($this->minimum !== null && ($value < $this->minimum || ($this->exclusiveMinimum === true && $value <= $this->minimum) ) ) { //error $return->errorObject = new IncorrectParametersException([ [ 'type' => static::getType(), 'failure' => 'minimum' ] ]); } elseif ($this->multipleOf !== null && fmod((float)$value, (float)$this->multipleOf) != 0 ) { //error $return->errorObject = new IncorrectParametersException([ [ 'type' => static::getType(), 'failure' => 'multipleOf' ] ]); } else { $return->errorObject = null; //Set status to success $return->status = true; //Type cast $return->value = $this->cast($value); } return $return; }
[ "protected", "function", "validateNumber", "(", "$", "value", ")", "{", "$", "return", "=", "new", "ValidateResult", "(", "$", "value", ",", "false", ")", ";", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "//Replace comma with dot", "$", "value", "=", "str_replace", "(", "','", ",", "'.'", ",", "$", "value", ")", ";", "}", "//Apply all rules", "if", "(", "!", "is_numeric", "(", "$", "value", ")", "||", "filter_var", "(", "$", "value", ",", "FILTER_VALIDATE_FLOAT", ")", "===", "false", ")", "{", "//error", "$", "return", "->", "errorObject", "=", "new", "IncorrectParametersException", "(", "[", "[", "'type'", "=>", "static", "::", "getType", "(", ")", ",", "'failure'", "=>", "'type'", "]", "]", ")", ";", "}", "elseif", "(", "$", "this", "->", "maximum", "!==", "null", "&&", "(", "$", "value", ">", "$", "this", "->", "maximum", "||", "(", "$", "this", "->", "exclusiveMaximum", "===", "true", "&&", "$", "value", ">=", "$", "this", "->", "maximum", ")", ")", ")", "{", "//error", "$", "return", "->", "errorObject", "=", "new", "IncorrectParametersException", "(", "[", "[", "'type'", "=>", "static", "::", "getType", "(", ")", ",", "'failure'", "=>", "'maximum'", "]", "]", ")", ";", "}", "elseif", "(", "$", "this", "->", "minimum", "!==", "null", "&&", "(", "$", "value", "<", "$", "this", "->", "minimum", "||", "(", "$", "this", "->", "exclusiveMinimum", "===", "true", "&&", "$", "value", "<=", "$", "this", "->", "minimum", ")", ")", ")", "{", "//error", "$", "return", "->", "errorObject", "=", "new", "IncorrectParametersException", "(", "[", "[", "'type'", "=>", "static", "::", "getType", "(", ")", ",", "'failure'", "=>", "'minimum'", "]", "]", ")", ";", "}", "elseif", "(", "$", "this", "->", "multipleOf", "!==", "null", "&&", "fmod", "(", "(", "float", ")", "$", "value", ",", "(", "float", ")", "$", "this", "->", "multipleOf", ")", "!=", "0", ")", "{", "//error", "$", "return", "->", "errorObject", "=", "new", "IncorrectParametersException", "(", "[", "[", "'type'", "=>", "static", "::", "getType", "(", ")", ",", "'failure'", "=>", "'multipleOf'", "]", "]", ")", ";", "}", "else", "{", "$", "return", "->", "errorObject", "=", "null", ";", "//Set status to success", "$", "return", "->", "status", "=", "true", ";", "//Type cast", "$", "return", "->", "value", "=", "$", "this", "->", "cast", "(", "$", "value", ")", ";", "}", "return", "$", "return", ";", "}" ]
Validate value, without calling validateCommon @see \Phramework\Validate\ValidateResult for ValidateResult object @param mixed $value Value to validate @return ValidateResult
[ "Validate", "value", "without", "calling", "validateCommon" ]
22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc
https://github.com/phramework/validate/blob/22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc/src/NumberValidator.php#L126-L187
16,597
contao-bootstrap/buttons
src/Netzmacht/Bootstrap/Buttons/Factory.php
Factory.createFromFieldset
public static function createFromFieldset($definition) { $definition = self::parseDefinition($definition); $root = new Group(); $group = $root; /** @var bool|Dropdown $dropdown */ $dropdown = false; $first = true; foreach ($definition as $button) { // dont add empty items if (self::isInvalidDefinition($button)) { continue; } // encode value $button = self::encodeValue($button); // finish dropdown if (self::hasToCloseDropdown($dropdown, $button)) { $dropdown = false; } if (in_array($button['type'], array('group', 'vgroup'))) { // create new group $group = self::createNewGroup($root, $button, $dropdown, !$first); } elseif ($button['type'] == 'dropdown') { // create dropdown $dropdown = static::createDropdown($button['label'], $button['attributes'], true); $dropdownGroup = static::createGroup(); $dropdownGroup->addChild($dropdown); $group->addChild($dropdownGroup); } elseif ($button['type'] == 'child' || $button['type'] == 'header') { // add dropdown child static::parseDropdownChild($dropdown, $button); } elseif ($dropdown !== false) { $child = static::createDropdownItem($button['label'], $button['url'], $button['attributes'], true); $dropdown->addChild($child); } else { $child = static::createButton($button['label'], $button['url'], $button['attributes'], true); $group->addChild($child); } $first = false; } return $root; }
php
public static function createFromFieldset($definition) { $definition = self::parseDefinition($definition); $root = new Group(); $group = $root; /** @var bool|Dropdown $dropdown */ $dropdown = false; $first = true; foreach ($definition as $button) { // dont add empty items if (self::isInvalidDefinition($button)) { continue; } // encode value $button = self::encodeValue($button); // finish dropdown if (self::hasToCloseDropdown($dropdown, $button)) { $dropdown = false; } if (in_array($button['type'], array('group', 'vgroup'))) { // create new group $group = self::createNewGroup($root, $button, $dropdown, !$first); } elseif ($button['type'] == 'dropdown') { // create dropdown $dropdown = static::createDropdown($button['label'], $button['attributes'], true); $dropdownGroup = static::createGroup(); $dropdownGroup->addChild($dropdown); $group->addChild($dropdownGroup); } elseif ($button['type'] == 'child' || $button['type'] == 'header') { // add dropdown child static::parseDropdownChild($dropdown, $button); } elseif ($dropdown !== false) { $child = static::createDropdownItem($button['label'], $button['url'], $button['attributes'], true); $dropdown->addChild($child); } else { $child = static::createButton($button['label'], $button['url'], $button['attributes'], true); $group->addChild($child); } $first = false; } return $root; }
[ "public", "static", "function", "createFromFieldset", "(", "$", "definition", ")", "{", "$", "definition", "=", "self", "::", "parseDefinition", "(", "$", "definition", ")", ";", "$", "root", "=", "new", "Group", "(", ")", ";", "$", "group", "=", "$", "root", ";", "/** @var bool|Dropdown $dropdown */", "$", "dropdown", "=", "false", ";", "$", "first", "=", "true", ";", "foreach", "(", "$", "definition", "as", "$", "button", ")", "{", "// dont add empty items", "if", "(", "self", "::", "isInvalidDefinition", "(", "$", "button", ")", ")", "{", "continue", ";", "}", "// encode value", "$", "button", "=", "self", "::", "encodeValue", "(", "$", "button", ")", ";", "// finish dropdown", "if", "(", "self", "::", "hasToCloseDropdown", "(", "$", "dropdown", ",", "$", "button", ")", ")", "{", "$", "dropdown", "=", "false", ";", "}", "if", "(", "in_array", "(", "$", "button", "[", "'type'", "]", ",", "array", "(", "'group'", ",", "'vgroup'", ")", ")", ")", "{", "// create new group", "$", "group", "=", "self", "::", "createNewGroup", "(", "$", "root", ",", "$", "button", ",", "$", "dropdown", ",", "!", "$", "first", ")", ";", "}", "elseif", "(", "$", "button", "[", "'type'", "]", "==", "'dropdown'", ")", "{", "// create dropdown", "$", "dropdown", "=", "static", "::", "createDropdown", "(", "$", "button", "[", "'label'", "]", ",", "$", "button", "[", "'attributes'", "]", ",", "true", ")", ";", "$", "dropdownGroup", "=", "static", "::", "createGroup", "(", ")", ";", "$", "dropdownGroup", "->", "addChild", "(", "$", "dropdown", ")", ";", "$", "group", "->", "addChild", "(", "$", "dropdownGroup", ")", ";", "}", "elseif", "(", "$", "button", "[", "'type'", "]", "==", "'child'", "||", "$", "button", "[", "'type'", "]", "==", "'header'", ")", "{", "// add dropdown child", "static", "::", "parseDropdownChild", "(", "$", "dropdown", ",", "$", "button", ")", ";", "}", "elseif", "(", "$", "dropdown", "!==", "false", ")", "{", "$", "child", "=", "static", "::", "createDropdownItem", "(", "$", "button", "[", "'label'", "]", ",", "$", "button", "[", "'url'", "]", ",", "$", "button", "[", "'attributes'", "]", ",", "true", ")", ";", "$", "dropdown", "->", "addChild", "(", "$", "child", ")", ";", "}", "else", "{", "$", "child", "=", "static", "::", "createButton", "(", "$", "button", "[", "'label'", "]", ",", "$", "button", "[", "'url'", "]", ",", "$", "button", "[", "'attributes'", "]", ",", "true", ")", ";", "$", "group", "->", "addChild", "(", "$", "child", ")", ";", "}", "$", "first", "=", "false", ";", "}", "return", "$", "root", ";", "}" ]
Create button from fieldset defintiion. @param string|array $definition Button definition. @return Group|Toolbar
[ "Create", "button", "from", "fieldset", "defintiion", "." ]
f573a24c19ec059aae528a12ba46dfc993844201
https://github.com/contao-bootstrap/buttons/blob/f573a24c19ec059aae528a12ba46dfc993844201/src/Netzmacht/Bootstrap/Buttons/Factory.php#L28-L79
16,598
contao-bootstrap/buttons
src/Netzmacht/Bootstrap/Buttons/Factory.php
Factory.createGroup
public static function createGroup(array $attributes = array(), $fromFieldset = false, $vertical = false) { $group = new Group(array(), $vertical); static::applyAttributes($group, $attributes, $fromFieldset); return $group; }
php
public static function createGroup(array $attributes = array(), $fromFieldset = false, $vertical = false) { $group = new Group(array(), $vertical); static::applyAttributes($group, $attributes, $fromFieldset); return $group; }
[ "public", "static", "function", "createGroup", "(", "array", "$", "attributes", "=", "array", "(", ")", ",", "$", "fromFieldset", "=", "false", ",", "$", "vertical", "=", "false", ")", "{", "$", "group", "=", "new", "Group", "(", "array", "(", ")", ",", "$", "vertical", ")", ";", "static", "::", "applyAttributes", "(", "$", "group", ",", "$", "attributes", ",", "$", "fromFieldset", ")", ";", "return", "$", "group", ";", "}" ]
Create button group. @param array $attributes Additional html attributes. @param bool $fromFieldset Set true if attributes comes from fieldset definitions have to be transformed. @param bool $vertical If true a vertical group is created. @return Group
[ "Create", "button", "group", "." ]
f573a24c19ec059aae528a12ba46dfc993844201
https://github.com/contao-bootstrap/buttons/blob/f573a24c19ec059aae528a12ba46dfc993844201/src/Netzmacht/Bootstrap/Buttons/Factory.php#L110-L116
16,599
contao-bootstrap/buttons
src/Netzmacht/Bootstrap/Buttons/Factory.php
Factory.createToolbar
public static function createToolbar(array $attributes = array(), $fromFieldset = false) { $toolbar = new Toolbar(); static::applyAttributes($toolbar, $attributes, $fromFieldset); return $toolbar; }
php
public static function createToolbar(array $attributes = array(), $fromFieldset = false) { $toolbar = new Toolbar(); static::applyAttributes($toolbar, $attributes, $fromFieldset); return $toolbar; }
[ "public", "static", "function", "createToolbar", "(", "array", "$", "attributes", "=", "array", "(", ")", ",", "$", "fromFieldset", "=", "false", ")", "{", "$", "toolbar", "=", "new", "Toolbar", "(", ")", ";", "static", "::", "applyAttributes", "(", "$", "toolbar", ",", "$", "attributes", ",", "$", "fromFieldset", ")", ";", "return", "$", "toolbar", ";", "}" ]
Create button toolbar. @param array $attributes Additional html attributes. @param bool $fromFieldset Set true if attributes comes from fieldset definitions have to be transformed. @return Toolbar
[ "Create", "button", "toolbar", "." ]
f573a24c19ec059aae528a12ba46dfc993844201
https://github.com/contao-bootstrap/buttons/blob/f573a24c19ec059aae528a12ba46dfc993844201/src/Netzmacht/Bootstrap/Buttons/Factory.php#L126-L132