repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/CookieJar.php
Zend_Http_CookieJar._matchDomain
protected function _matchDomain($domain) { $ret = array(); foreach (array_keys($this->cookies) as $cdom) { $regex = "/" . preg_quote($cdom, "/") . "$/i"; if (preg_match($regex, $domain)) { $ret[$cdom] = &$this->cookies[$cdom]; } } return $ret; }
php
protected function _matchDomain($domain) { $ret = array(); foreach (array_keys($this->cookies) as $cdom) { $regex = "/" . preg_quote($cdom, "/") . "$/i"; if (preg_match($regex, $domain)) { $ret[$cdom] = &$this->cookies[$cdom]; } } return $ret; }
[ "protected", "function", "_matchDomain", "(", "$", "domain", ")", "{", "$", "ret", "=", "array", "(", ")", ";", "foreach", "(", "array_keys", "(", "$", "this", "->", "cookies", ")", "as", "$", "cdom", ")", "{", "$", "regex", "=", "\"/\"", ".", "pre...
Return a subset of the cookies array matching a specific domain Returned array is actually an array of pointers to items in the $this->cookies array. @param string $domain @return array
[ "Return", "a", "subset", "of", "the", "cookies", "array", "matching", "a", "specific", "domain" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/CookieJar.php#L303-L314
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/CookieJar.php
Zend_Http_CookieJar._matchPath
protected function _matchPath($domains, $path) { $ret = array(); if (substr($path, -1) != '/') { $path .= '/'; } foreach ($domains as $dom => $paths_array) { foreach (array_keys($paths_array) as $cpath) { $regex = "|^" . preg_quote($cpath, "|") . "|i"; if (preg_match($regex, $path)) { if (! isset($ret[$dom])) { $ret[$dom] = array(); } $ret[$dom][$cpath] = &$paths_array[$cpath]; } } } return $ret; }
php
protected function _matchPath($domains, $path) { $ret = array(); if (substr($path, -1) != '/') { $path .= '/'; } foreach ($domains as $dom => $paths_array) { foreach (array_keys($paths_array) as $cpath) { $regex = "|^" . preg_quote($cpath, "|") . "|i"; if (preg_match($regex, $path)) { if (! isset($ret[$dom])) { $ret[$dom] = array(); } $ret[$dom][$cpath] = &$paths_array[$cpath]; } } } return $ret; }
[ "protected", "function", "_matchPath", "(", "$", "domains", ",", "$", "path", ")", "{", "$", "ret", "=", "array", "(", ")", ";", "if", "(", "substr", "(", "$", "path", ",", "-", "1", ")", "!=", "'/'", ")", "{", "$", "path", ".=", "'/'", ";", ...
Return a subset of a domain-matching cookies that also match a specified path Returned array is actually an array of pointers to items in the $passed array. @param array $dom_array @param string $path @return array
[ "Return", "a", "subset", "of", "a", "domain", "-", "matching", "cookies", "that", "also", "match", "a", "specified", "path" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/CookieJar.php#L325-L343
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/CookieJar.php
Zend_Http_CookieJar.fromResponse
public static function fromResponse(Zend_Http_Response $response, $ref_uri) { $jar = new self(); $jar->addCookiesFromResponse($response, $ref_uri); return $jar; }
php
public static function fromResponse(Zend_Http_Response $response, $ref_uri) { $jar = new self(); $jar->addCookiesFromResponse($response, $ref_uri); return $jar; }
[ "public", "static", "function", "fromResponse", "(", "Zend_Http_Response", "$", "response", ",", "$", "ref_uri", ")", "{", "$", "jar", "=", "new", "self", "(", ")", ";", "$", "jar", "->", "addCookiesFromResponse", "(", "$", "response", ",", "$", "ref_uri",...
Create a new CookieJar object and automatically load into it all the cookies set in an Http_Response object. If $uri is set, it will be considered as the requested URI for setting default domain and path of the cookie. @param Zend_Http_Response $response HTTP Response object @param Zend_Uri_Http|string $uri The requested URI @return Zend_Http_CookieJar @todo Add the $uri functionality.
[ "Create", "a", "new", "CookieJar", "object", "and", "automatically", "load", "into", "it", "all", "the", "cookies", "set", "in", "an", "Http_Response", "object", ".", "If", "$uri", "is", "set", "it", "will", "be", "considered", "as", "the", "requested", "U...
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/CookieJar.php#L356-L361
oxygen-cms/core
src/Form/FieldSet.php
FieldSet.getFields
public function getFields() { if($this->cachedFields == null) { $this->cachedFields = $this->createFields(); } return $this->cachedFields; }
php
public function getFields() { if($this->cachedFields == null) { $this->cachedFields = $this->createFields(); } return $this->cachedFields; }
[ "public", "function", "getFields", "(", ")", "{", "if", "(", "$", "this", "->", "cachedFields", "==", "null", ")", "{", "$", "this", "->", "cachedFields", "=", "$", "this", "->", "createFields", "(", ")", ";", "}", "return", "$", "this", "->", "cache...
Returns the fields in the set. @return array
[ "Returns", "the", "fields", "in", "the", "set", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Form/FieldSet.php#L26-L32
oxygen-cms/core
src/Form/FieldSet.php
FieldSet.makeFields
public function makeFields(array $fields) { $results = []; foreach($fields as $field) { $name = $field['name']; unset($field['name']); $results[$name] = $this->makeField($name, $field); } return $results; }
php
public function makeFields(array $fields) { $results = []; foreach($fields as $field) { $name = $field['name']; unset($field['name']); $results[$name] = $this->makeField($name, $field); } return $results; }
[ "public", "function", "makeFields", "(", "array", "$", "fields", ")", "{", "$", "results", "=", "[", "]", ";", "foreach", "(", "$", "fields", "as", "$", "field", ")", "{", "$", "name", "=", "$", "field", "[", "'name'", "]", ";", "unset", "(", "$"...
Creates multiple new fields @param $fields @return array
[ "Creates", "multiple", "new", "fields" ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Form/FieldSet.php#L63-L72
oxygen-cms/core
src/Form/FieldSet.php
FieldSet.makeField
public function makeField($name, $arguments) { $field = new FieldMetadata($name); foreach($arguments as $key => $value) { $field->$key = $value; } return $field; }
php
public function makeField($name, $arguments) { $field = new FieldMetadata($name); foreach($arguments as $key => $value) { $field->$key = $value; } return $field; }
[ "public", "function", "makeField", "(", "$", "name", ",", "$", "arguments", ")", "{", "$", "field", "=", "new", "FieldMetadata", "(", "$", "name", ")", ";", "foreach", "(", "$", "arguments", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "fie...
Creates a new field @param $name @param $arguments @return \Oxygen\Core\Form\FieldMetadata
[ "Creates", "a", "new", "field" ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Form/FieldSet.php#L81-L88
krafthaus/bauhaus
src/controllers/Modal/ModelController.php
ModelController.delete
public function delete($name) { $model = sprintf('\\%sAdmin', Str::studly($name)); $model = (new $model)->buildForm(); return View::make('krafthaus/bauhaus::models.modals.delete') ->with('name', $name) ->with('model', $model); }
php
public function delete($name) { $model = sprintf('\\%sAdmin', Str::studly($name)); $model = (new $model)->buildForm(); return View::make('krafthaus/bauhaus::models.modals.delete') ->with('name', $name) ->with('model', $model); }
[ "public", "function", "delete", "(", "$", "name", ")", "{", "$", "model", "=", "sprintf", "(", "'\\\\%sAdmin'", ",", "Str", "::", "studly", "(", "$", "name", ")", ")", ";", "$", "model", "=", "(", "new", "$", "model", ")", "->", "buildForm", "(", ...
Show the form for creating a new resource. @param string $model @access public @return Response
[ "Show", "the", "form", "for", "creating", "a", "new", "resource", "." ]
train
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/controllers/Modal/ModelController.php#L32-L40
schmunk42/p3extensions
components/image/Image_Driver.php
Image_Driver.execute
public function execute($actions) { foreach ($actions as $func => $args) { if ( ! $this->$func($args)) return FALSE; } return TRUE; }
php
public function execute($actions) { foreach ($actions as $func => $args) { if ( ! $this->$func($args)) return FALSE; } return TRUE; }
[ "public", "function", "execute", "(", "$", "actions", ")", "{", "foreach", "(", "$", "actions", "as", "$", "func", "=>", "$", "args", ")", "{", "if", "(", "!", "$", "this", "->", "$", "func", "(", "$", "args", ")", ")", "return", "FALSE", ";", ...
Executes a set of actions, defined in pairs. @param array actions @return boolean
[ "Executes", "a", "set", "of", "actions", "defined", "in", "pairs", "." ]
train
https://github.com/schmunk42/p3extensions/blob/93999c06fc8e3eadd83983d001df231e46b06838/components/image/Image_Driver.php#L29-L38
schmunk42/p3extensions
components/image/Image_Driver.php
Image_Driver.sanitize_geometry
protected function sanitize_geometry( & $geometry) { list($width, $height) = $this->properties(); // Turn off error reporting $reporting = error_reporting(0); // Width and height cannot exceed current image size $geometry['width'] = min($geometry['width'], $width); $geometry['height'] = min($geometry['height'], $height); // Set standard coordinates if given, otherwise use pixel values if ($geometry['top'] === 'center') { $geometry['top'] = floor(($height / 2) - ($geometry['height'] / 2)); } elseif ($geometry['top'] === 'top') { $geometry['top'] = 0; } elseif ($geometry['top'] === 'bottom') { $geometry['top'] = $height - $geometry['height']; } // Set standard coordinates if given, otherwise use pixel values if ($geometry['left'] === 'center') { $geometry['left'] = floor(($width / 2) - ($geometry['width'] / 2)); } elseif ($geometry['left'] === 'left') { $geometry['left'] = 0; } elseif ($geometry['left'] === 'right') { $geometry['left'] = $width - $geometry['height']; } // Restore error reporting error_reporting($reporting); }
php
protected function sanitize_geometry( & $geometry) { list($width, $height) = $this->properties(); // Turn off error reporting $reporting = error_reporting(0); // Width and height cannot exceed current image size $geometry['width'] = min($geometry['width'], $width); $geometry['height'] = min($geometry['height'], $height); // Set standard coordinates if given, otherwise use pixel values if ($geometry['top'] === 'center') { $geometry['top'] = floor(($height / 2) - ($geometry['height'] / 2)); } elseif ($geometry['top'] === 'top') { $geometry['top'] = 0; } elseif ($geometry['top'] === 'bottom') { $geometry['top'] = $height - $geometry['height']; } // Set standard coordinates if given, otherwise use pixel values if ($geometry['left'] === 'center') { $geometry['left'] = floor(($width / 2) - ($geometry['width'] / 2)); } elseif ($geometry['left'] === 'left') { $geometry['left'] = 0; } elseif ($geometry['left'] === 'right') { $geometry['left'] = $width - $geometry['height']; } // Restore error reporting error_reporting($reporting); }
[ "protected", "function", "sanitize_geometry", "(", "&", "$", "geometry", ")", "{", "list", "(", "$", "width", ",", "$", "height", ")", "=", "$", "this", "->", "properties", "(", ")", ";", "// Turn off error reporting", "$", "reporting", "=", "error_reporting...
Sanitize and normalize a geometry array based on the temporary image width and height. Valid properties are: width, height, top, left. @param array geometry properties @return void
[ "Sanitize", "and", "normalize", "a", "geometry", "array", "based", "on", "the", "temporary", "image", "width", "and", "height", ".", "Valid", "properties", "are", ":", "width", "height", "top", "left", "." ]
train
https://github.com/schmunk42/p3extensions/blob/93999c06fc8e3eadd83983d001df231e46b06838/components/image/Image_Driver.php#L47-L88
txj123/zilf
src/Zilf/Cache/FileStore.php
FileStore.put
public function put($key, $value, $minutes) { $this->ensureCacheDirectoryExists($path = $this->path($key)); $this->files->put( $path, $this->expiration($minutes).serialize($value), true ); }
php
public function put($key, $value, $minutes) { $this->ensureCacheDirectoryExists($path = $this->path($key)); $this->files->put( $path, $this->expiration($minutes).serialize($value), true ); }
[ "public", "function", "put", "(", "$", "key", ",", "$", "value", ",", "$", "minutes", ")", "{", "$", "this", "->", "ensureCacheDirectoryExists", "(", "$", "path", "=", "$", "this", "->", "path", "(", "$", "key", ")", ")", ";", "$", "this", "->", ...
Store an item in the cache for a given number of minutes. @param string $key @param mixed $value @param float|int $minutes @return void
[ "Store", "an", "item", "in", "the", "cache", "for", "a", "given", "number", "of", "minutes", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Cache/FileStore.php#L60-L67
txj123/zilf
src/Zilf/Cache/FileStore.php
FileStore.ensureCacheDirectoryExists
protected function ensureCacheDirectoryExists($path) { if (! $this->files->exists(dirname($path))) { $this->files->mkdir(dirname($path), 0777); } }
php
protected function ensureCacheDirectoryExists($path) { if (! $this->files->exists(dirname($path))) { $this->files->mkdir(dirname($path), 0777); } }
[ "protected", "function", "ensureCacheDirectoryExists", "(", "$", "path", ")", "{", "if", "(", "!", "$", "this", "->", "files", "->", "exists", "(", "dirname", "(", "$", "path", ")", ")", ")", "{", "$", "this", "->", "files", "->", "mkdir", "(", "dirn...
Create the file cache directory if necessary. @param string $path @return void
[ "Create", "the", "file", "cache", "directory", "if", "necessary", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Cache/FileStore.php#L75-L80
txj123/zilf
src/Zilf/Cache/FileStore.php
FileStore.increment
public function increment($key, $value = 1) { $raw = $this->getPayload($key); return tap( ((int) $raw['data']) + $value, function ($newValue) use ($key, $raw) { $this->put($key, $newValue, $raw['time']); } ); }
php
public function increment($key, $value = 1) { $raw = $this->getPayload($key); return tap( ((int) $raw['data']) + $value, function ($newValue) use ($key, $raw) { $this->put($key, $newValue, $raw['time']); } ); }
[ "public", "function", "increment", "(", "$", "key", ",", "$", "value", "=", "1", ")", "{", "$", "raw", "=", "$", "this", "->", "getPayload", "(", "$", "key", ")", ";", "return", "tap", "(", "(", "(", "int", ")", "$", "raw", "[", "'data'", "]", ...
Increment the value of an item in the cache. @param string $key @param mixed $value @return int
[ "Increment", "the", "value", "of", "an", "item", "in", "the", "cache", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Cache/FileStore.php#L89-L98
txj123/zilf
src/Zilf/Cache/FileStore.php
FileStore.expiration
protected function expiration($minutes) { $time = time() + (int) ($minutes * 60); return $minutes === 0 || $time > 9999999999 ? 9999999999 : (int) $time; }
php
protected function expiration($minutes) { $time = time() + (int) ($minutes * 60); return $minutes === 0 || $time > 9999999999 ? 9999999999 : (int) $time; }
[ "protected", "function", "expiration", "(", "$", "minutes", ")", "{", "$", "time", "=", "time", "(", ")", "+", "(", "int", ")", "(", "$", "minutes", "*", "60", ")", ";", "return", "$", "minutes", "===", "0", "||", "$", "time", ">", "9999999999", ...
Get the expiration time based on the given minutes. @param float|int $minutes @return int
[ "Get", "the", "expiration", "time", "based", "on", "the", "given", "minutes", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Cache/FileStore.php#L228-L233
oxygen-cms/core
src/Blueprint/Blueprint.php
Blueprint.getRouteName
public function getRouteName($actionName = null) { $name = Str::camel($this->pluralName); return $actionName == null ? $name : $name . '.' . $actionName; }
php
public function getRouteName($actionName = null) { $name = Str::camel($this->pluralName); return $actionName == null ? $name : $name . '.' . $actionName; }
[ "public", "function", "getRouteName", "(", "$", "actionName", "=", "null", ")", "{", "$", "name", "=", "Str", "::", "camel", "(", "$", "this", "->", "pluralName", ")", ";", "return", "$", "actionName", "==", "null", "?", "$", "name", ":", "$", "name"...
Returns the camel cased name of the Blueprint. Used for route names. If the $actionName parameter is provided then it will be concatenated onto the end of the route. @param string $actionName @return string
[ "Returns", "the", "camel", "cased", "name", "of", "the", "Blueprint", ".", "Used", "for", "route", "names", ".", "If", "the", "$actionName", "parameter", "is", "provided", "then", "it", "will", "be", "concatenated", "onto", "the", "end", "of", "the", "rout...
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Blueprint/Blueprint.php#L232-L236
oxygen-cms/core
src/Blueprint/Blueprint.php
Blueprint.getRoutePattern
public function getRoutePattern() { $slug = Str::slug(Str::camelToWords($this->pluralName)); return $this->baseURI !== '/' ? $this->baseURI . '/' . $slug : $slug; }
php
public function getRoutePattern() { $slug = Str::slug(Str::camelToWords($this->pluralName)); return $this->baseURI !== '/' ? $this->baseURI . '/' . $slug : $slug; }
[ "public", "function", "getRoutePattern", "(", ")", "{", "$", "slug", "=", "Str", "::", "slug", "(", "Str", "::", "camelToWords", "(", "$", "this", "->", "pluralName", ")", ")", ";", "return", "$", "this", "->", "baseURI", "!==", "'/'", "?", "$", "thi...
Returns the slugified version of the Blueprint name. Used as a prefix for all admin routes. @return string
[ "Returns", "the", "slugified", "version", "of", "the", "Blueprint", "name", ".", "Used", "as", "a", "prefix", "for", "all", "admin", "routes", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Blueprint/Blueprint.php#L244-L248
oxygen-cms/core
src/Blueprint/Blueprint.php
Blueprint.getAction
public function getAction($name) { if(isset($this->actions[$name])) { return $this->actions[$name]; } else { throw new InvalidArgumentException('Action does not exist: ' . $name); } }
php
public function getAction($name) { if(isset($this->actions[$name])) { return $this->actions[$name]; } else { throw new InvalidArgumentException('Action does not exist: ' . $name); } }
[ "public", "function", "getAction", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "actions", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "actions", "[", "$", "name", "]", ";", "}", "else", "{", "t...
Get an action by its name. @param string $name @return Action
[ "Get", "an", "action", "by", "its", "name", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Blueprint/Blueprint.php#L344-L350
oxygen-cms/core
src/Blueprint/Blueprint.php
Blueprint.makeAction
public function makeAction(array $parameters, FactoryInterface $factory = null) { if($factory === null) { $factory = $this->getDefaultActionFactory(); } if(!isset($parameters['group'])) { $parameters['group'] = new Group($this->getRouteName(), $this->getRoutePattern()); } $action = $factory->create($parameters, $this->getController()); $this->addAction($action); return $action; }
php
public function makeAction(array $parameters, FactoryInterface $factory = null) { if($factory === null) { $factory = $this->getDefaultActionFactory(); } if(!isset($parameters['group'])) { $parameters['group'] = new Group($this->getRouteName(), $this->getRoutePattern()); } $action = $factory->create($parameters, $this->getController()); $this->addAction($action); return $action; }
[ "public", "function", "makeAction", "(", "array", "$", "parameters", ",", "FactoryInterface", "$", "factory", "=", "null", ")", "{", "if", "(", "$", "factory", "===", "null", ")", "{", "$", "factory", "=", "$", "this", "->", "getDefaultActionFactory", "(",...
Adds an action. @param array $parameters @param FactoryInterface $factory Optional FactoryInterface @return Action
[ "Adds", "an", "action", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Blueprint/Blueprint.php#L378-L392
oxygen-cms/core
src/Blueprint/Blueprint.php
Blueprint.getToolbarItem
public function getToolbarItem($name) { if(!isset($this->toolbarItems[$name])) { return $this->toolbarItems[$this->getRouteName() . '.' . $name]; } return $this->toolbarItems[$name]; }
php
public function getToolbarItem($name) { if(!isset($this->toolbarItems[$name])) { return $this->toolbarItems[$this->getRouteName() . '.' . $name]; } return $this->toolbarItems[$name]; }
[ "public", "function", "getToolbarItem", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "toolbarItems", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "toolbarItems", "[", "$", "this", "->", "getRouteN...
Get an toolbar item by its name. @param string $name @return ToolbarItem
[ "Get", "an", "toolbar", "item", "by", "its", "name", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Blueprint/Blueprint.php#L472-L478
oxygen-cms/core
src/Blueprint/Blueprint.php
Blueprint.makeToolbarItem
public function makeToolbarItem(array $parameters, FactoryInterface $factory = null) { if($factory === null) { $factory = $this->getDefaultToolbarItemFactory(); } if(is_string($parameters['action'])) { $parameters['action'] = $this->getAction($parameters['action']); } $item = $factory->create($parameters); $this->addToolbarItem($item); return $item; }
php
public function makeToolbarItem(array $parameters, FactoryInterface $factory = null) { if($factory === null) { $factory = $this->getDefaultToolbarItemFactory(); } if(is_string($parameters['action'])) { $parameters['action'] = $this->getAction($parameters['action']); } $item = $factory->create($parameters); $this->addToolbarItem($item); return $item; }
[ "public", "function", "makeToolbarItem", "(", "array", "$", "parameters", ",", "FactoryInterface", "$", "factory", "=", "null", ")", "{", "if", "(", "$", "factory", "===", "null", ")", "{", "$", "factory", "=", "$", "this", "->", "getDefaultToolbarItemFactor...
Makes a new toolbar item and adds it to the Blueprint. @param array $parameters @param FactoryInterface $factory Optional FactoryInterface @return Action
[ "Makes", "a", "new", "toolbar", "item", "and", "adds", "it", "to", "the", "Blueprint", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Blueprint/Blueprint.php#L506-L520
oxygen-cms/core
src/Blueprint/Blueprint.php
Blueprint.removeToolbarItem
public function removeToolbarItem($name) { if(!isset($this->toolbarItems[$name])) { unset($this->toolbarItems[$this->getRouteName() . '.' . $name]); } unset($this->toolbarItems[$name]); }
php
public function removeToolbarItem($name) { if(!isset($this->toolbarItems[$name])) { unset($this->toolbarItems[$this->getRouteName() . '.' . $name]); } unset($this->toolbarItems[$name]); }
[ "public", "function", "removeToolbarItem", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "toolbarItems", "[", "$", "name", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "toolbarItems", "[", "$", "this", "->", "...
Remove a toolbar item. @param string $name @return void
[ "Remove", "a", "toolbar", "item", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Blueprint/Blueprint.php#L528-L534
oxygen-cms/core
src/Blueprint/BlueprintManager.php
BlueprintManager.loadDirectory
public function loadDirectory($directory) { $iterator = new DirectoryIterator($directory); foreach($iterator as $file) { if($file->isFile() && ends_with($file->getFilename(), '.php')) { require $directory . '/' . $file->getFilename(); } } }
php
public function loadDirectory($directory) { $iterator = new DirectoryIterator($directory); foreach($iterator as $file) { if($file->isFile() && ends_with($file->getFilename(), '.php')) { require $directory . '/' . $file->getFilename(); } } }
[ "public", "function", "loadDirectory", "(", "$", "directory", ")", "{", "$", "iterator", "=", "new", "DirectoryIterator", "(", "$", "directory", ")", ";", "foreach", "(", "$", "iterator", "as", "$", "file", ")", "{", "if", "(", "$", "file", "->", "isFi...
Loads a directory of files. @param string $directory @return void
[ "Loads", "a", "directory", "of", "files", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Blueprint/BlueprintManager.php#L53-L60
oxygen-cms/core
src/Blueprint/BlueprintManager.php
BlueprintManager.registerRoutes
public function registerRoutes(BlueprintRegistrar $registrar) { $registrar->getRouter()->pattern('id', '[0-9]+'); foreach($this->all() as $blueprint) { $registrar->blueprint($blueprint); } $registrar->registerFinal(); }
php
public function registerRoutes(BlueprintRegistrar $registrar) { $registrar->getRouter()->pattern('id', '[0-9]+'); foreach($this->all() as $blueprint) { $registrar->blueprint($blueprint); } $registrar->registerFinal(); }
[ "public", "function", "registerRoutes", "(", "BlueprintRegistrar", "$", "registrar", ")", "{", "$", "registrar", "->", "getRouter", "(", ")", "->", "pattern", "(", "'id'", ",", "'[0-9]+'", ")", ";", "foreach", "(", "$", "this", "->", "all", "(", ")", "as...
Constructs the BlueprintManager. @param \Oxygen\Core\Contracts\Routing\BlueprintRegistrar $registrar
[ "Constructs", "the", "BlueprintManager", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Blueprint/BlueprintManager.php#L67-L75
oxygen-cms/core
src/Blueprint/BlueprintManager.php
BlueprintManager.make
public function make($name, callable $callback) { $blueprint = new Blueprint($name, $this->config->getAdminURIPrefix()); $callback($blueprint); $this->blueprints[$blueprint->getName()] = $blueprint; if($blueprint->hasPrimaryToolbarItem()) { $this->navigation->add($blueprint->getPrimaryToolbarItem()); } }
php
public function make($name, callable $callback) { $blueprint = new Blueprint($name, $this->config->getAdminURIPrefix()); $callback($blueprint); $this->blueprints[$blueprint->getName()] = $blueprint; if($blueprint->hasPrimaryToolbarItem()) { $this->navigation->add($blueprint->getPrimaryToolbarItem()); } }
[ "public", "function", "make", "(", "$", "name", ",", "callable", "$", "callback", ")", "{", "$", "blueprint", "=", "new", "Blueprint", "(", "$", "name", ",", "$", "this", "->", "config", "->", "getAdminURIPrefix", "(", ")", ")", ";", "$", "callback", ...
Make a new Blueprint. @param string $name display name of the blueprint @param callable $callback @return void
[ "Make", "a", "new", "Blueprint", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Blueprint/BlueprintManager.php#L84-L92
oxygen-cms/core
src/Blueprint/BlueprintManager.php
BlueprintManager.get
public function get($name) { if(isset($this->blueprints[$name])) { return $this->blueprints[$name]; } else { throw new BlueprintNotFoundException('Blueprint not found: "' . $name . '"'); } }
php
public function get($name) { if(isset($this->blueprints[$name])) { return $this->blueprints[$name]; } else { throw new BlueprintNotFoundException('Blueprint not found: "' . $name . '"'); } }
[ "public", "function", "get", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "blueprints", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "blueprints", "[", "$", "name", "]", ";", "}", "else", "{", "t...
Get a Blueprint. @param string $name blueprint @return Blueprint @throws BlueprintNotFoundException if the Blueprint can't be found
[ "Get", "a", "Blueprint", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Blueprint/BlueprintManager.php#L101-L107
txj123/zilf
src/Zilf/HttpFoundation/BinaryFileResponse.php
BinaryFileResponse.setContentDisposition
public function setContentDisposition($disposition, $filename = '', $filenameFallback = '') { if ($filename === '') { $filename = $this->file->getFilename(); } if ('' === $filenameFallback && (!preg_match('/^[\x20-\x7e]*$/', $filename) || false !== strpos($filename, '%'))) { $encoding = mb_detect_encoding($filename, null, true); for ($i = 0, $filenameLength = mb_strlen($filename, $encoding); $i < $filenameLength; ++$i) { $char = mb_substr($filename, $i, 1, $encoding); if ('%' === $char || ord($char) < 32 || ord($char) > 126) { $filenameFallback .= '_'; } else { $filenameFallback .= $char; } } } $dispositionHeader = $this->headers->makeDisposition($disposition, $filename, $filenameFallback); $this->headers->set('Content-Disposition', $dispositionHeader); return $this; }
php
public function setContentDisposition($disposition, $filename = '', $filenameFallback = '') { if ($filename === '') { $filename = $this->file->getFilename(); } if ('' === $filenameFallback && (!preg_match('/^[\x20-\x7e]*$/', $filename) || false !== strpos($filename, '%'))) { $encoding = mb_detect_encoding($filename, null, true); for ($i = 0, $filenameLength = mb_strlen($filename, $encoding); $i < $filenameLength; ++$i) { $char = mb_substr($filename, $i, 1, $encoding); if ('%' === $char || ord($char) < 32 || ord($char) > 126) { $filenameFallback .= '_'; } else { $filenameFallback .= $char; } } } $dispositionHeader = $this->headers->makeDisposition($disposition, $filename, $filenameFallback); $this->headers->set('Content-Disposition', $dispositionHeader); return $this; }
[ "public", "function", "setContentDisposition", "(", "$", "disposition", ",", "$", "filename", "=", "''", ",", "$", "filenameFallback", "=", "''", ")", "{", "if", "(", "$", "filename", "===", "''", ")", "{", "$", "filename", "=", "$", "this", "->", "fil...
Sets the Content-Disposition header with the given filename. @param string $disposition ResponseHeaderBag::DISPOSITION_INLINE or ResponseHeaderBag::DISPOSITION_ATTACHMENT @param string $filename Optionally use this filename instead of the real name of the file @param string $filenameFallback A fallback filename, containing only ASCII characters. Defaults to an automatically encoded filename @return $this
[ "Sets", "the", "Content", "-", "Disposition", "header", "with", "the", "given", "filename", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/BinaryFileResponse.php#L158-L182
txj123/zilf
src/Zilf/HttpFoundation/BinaryFileResponse.php
BinaryFileResponse.prepare
public function prepare(Request $request) { if (!$this->headers->has('Content-Type')) { $this->headers->set('Content-Type', $this->file->getMimeType() ?: 'application/octet-stream'); } if ('HTTP/1.0' !== $request->server->get('SERVER_PROTOCOL')) { $this->setProtocolVersion('1.1'); } $this->ensureIEOverSSLCompatibility($request); $this->offset = 0; $this->maxlen = -1; if (false === $fileSize = $this->file->getSize()) { return $this; } $this->headers->set('Content-Length', $fileSize); if (!$this->headers->has('Accept-Ranges')) { // Only accept ranges on safe HTTP methods $this->headers->set('Accept-Ranges', $request->isMethodSafe(false) ? 'bytes' : 'none'); } if (self::$trustXSendfileTypeHeader && $request->headers->has('X-Sendfile-Type')) { // Use X-Sendfile, do not send any content. $type = $request->headers->get('X-Sendfile-Type'); $path = $this->file->getRealPath(); // Fall back to scheme://path for stream wrapped locations. if (false === $path) { $path = $this->file->getPathname(); } if (strtolower($type) === 'x-accel-redirect') { // Do X-Accel-Mapping substitutions. // @link http://wiki.nginx.org/X-accel#X-Accel-Redirect foreach (explode(',', $request->headers->get('X-Accel-Mapping', '')) as $mapping) { $mapping = explode('=', $mapping, 2); if (2 === count($mapping)) { $pathPrefix = trim($mapping[0]); $location = trim($mapping[1]); if (substr($path, 0, strlen($pathPrefix)) === $pathPrefix) { $path = $location.substr($path, strlen($pathPrefix)); break; } } } } $this->headers->set($type, $path); $this->maxlen = 0; } elseif ($request->headers->has('Range')) { // Process the range headers. if (!$request->headers->has('If-Range') || $this->hasValidIfRangeHeader($request->headers->get('If-Range'))) { $range = $request->headers->get('Range'); list($start, $end) = explode('-', substr($range, 6), 2) + array(0); $end = ('' === $end) ? $fileSize - 1 : (int) $end; if ('' === $start) { $start = $fileSize - $end; $end = $fileSize - 1; } else { $start = (int) $start; } if ($start <= $end) { if ($start < 0 || $end > $fileSize - 1) { $this->setStatusCode(416); $this->headers->set('Content-Range', sprintf('bytes */%s', $fileSize)); } elseif ($start !== 0 || $end !== $fileSize - 1) { $this->maxlen = $end < $fileSize ? $end - $start + 1 : -1; $this->offset = $start; $this->setStatusCode(206); $this->headers->set('Content-Range', sprintf('bytes %s-%s/%s', $start, $end, $fileSize)); $this->headers->set('Content-Length', $end - $start + 1); } } } } return $this; }
php
public function prepare(Request $request) { if (!$this->headers->has('Content-Type')) { $this->headers->set('Content-Type', $this->file->getMimeType() ?: 'application/octet-stream'); } if ('HTTP/1.0' !== $request->server->get('SERVER_PROTOCOL')) { $this->setProtocolVersion('1.1'); } $this->ensureIEOverSSLCompatibility($request); $this->offset = 0; $this->maxlen = -1; if (false === $fileSize = $this->file->getSize()) { return $this; } $this->headers->set('Content-Length', $fileSize); if (!$this->headers->has('Accept-Ranges')) { // Only accept ranges on safe HTTP methods $this->headers->set('Accept-Ranges', $request->isMethodSafe(false) ? 'bytes' : 'none'); } if (self::$trustXSendfileTypeHeader && $request->headers->has('X-Sendfile-Type')) { // Use X-Sendfile, do not send any content. $type = $request->headers->get('X-Sendfile-Type'); $path = $this->file->getRealPath(); // Fall back to scheme://path for stream wrapped locations. if (false === $path) { $path = $this->file->getPathname(); } if (strtolower($type) === 'x-accel-redirect') { // Do X-Accel-Mapping substitutions. // @link http://wiki.nginx.org/X-accel#X-Accel-Redirect foreach (explode(',', $request->headers->get('X-Accel-Mapping', '')) as $mapping) { $mapping = explode('=', $mapping, 2); if (2 === count($mapping)) { $pathPrefix = trim($mapping[0]); $location = trim($mapping[1]); if (substr($path, 0, strlen($pathPrefix)) === $pathPrefix) { $path = $location.substr($path, strlen($pathPrefix)); break; } } } } $this->headers->set($type, $path); $this->maxlen = 0; } elseif ($request->headers->has('Range')) { // Process the range headers. if (!$request->headers->has('If-Range') || $this->hasValidIfRangeHeader($request->headers->get('If-Range'))) { $range = $request->headers->get('Range'); list($start, $end) = explode('-', substr($range, 6), 2) + array(0); $end = ('' === $end) ? $fileSize - 1 : (int) $end; if ('' === $start) { $start = $fileSize - $end; $end = $fileSize - 1; } else { $start = (int) $start; } if ($start <= $end) { if ($start < 0 || $end > $fileSize - 1) { $this->setStatusCode(416); $this->headers->set('Content-Range', sprintf('bytes */%s', $fileSize)); } elseif ($start !== 0 || $end !== $fileSize - 1) { $this->maxlen = $end < $fileSize ? $end - $start + 1 : -1; $this->offset = $start; $this->setStatusCode(206); $this->headers->set('Content-Range', sprintf('bytes %s-%s/%s', $start, $end, $fileSize)); $this->headers->set('Content-Length', $end - $start + 1); } } } } return $this; }
[ "public", "function", "prepare", "(", "Request", "$", "request", ")", "{", "if", "(", "!", "$", "this", "->", "headers", "->", "has", "(", "'Content-Type'", ")", ")", "{", "$", "this", "->", "headers", "->", "set", "(", "'Content-Type'", ",", "$", "t...
{@inheritdoc}
[ "{" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/BinaryFileResponse.php#L187-L272
dave-redfern/laravel-doctrine-tenancy
src/Console/TenantListCommand.php
TenantListCommand.fire
public function fire() { $data = []; /** @var DomainAwareTenantParticipant $tenant */ foreach ($this->repository->findBy([], ['name' => 'ASC']) as $tenant) { $data[] = [ 'id' => $tenant->getId(), 'name' => $tenant->getName(), 'domain' => $tenant->getDomain(), 'owner' => $tenant->getTenantOwner()->getName(), 'model' => $tenant->getSecurityModel(), ]; } $this->table($this->headers, $data); }
php
public function fire() { $data = []; /** @var DomainAwareTenantParticipant $tenant */ foreach ($this->repository->findBy([], ['name' => 'ASC']) as $tenant) { $data[] = [ 'id' => $tenant->getId(), 'name' => $tenant->getName(), 'domain' => $tenant->getDomain(), 'owner' => $tenant->getTenantOwner()->getName(), 'model' => $tenant->getSecurityModel(), ]; } $this->table($this->headers, $data); }
[ "public", "function", "fire", "(", ")", "{", "$", "data", "=", "[", "]", ";", "/** @var DomainAwareTenantParticipant $tenant */", "foreach", "(", "$", "this", "->", "repository", "->", "findBy", "(", "[", "]", ",", "[", "'name'", "=>", "'ASC'", "]", ")", ...
Execute the console command. @return void
[ "Execute", "the", "console", "command", "." ]
train
https://github.com/dave-redfern/laravel-doctrine-tenancy/blob/3307fc57ad64d5a4dd5dfb235e19b301661255f9/src/Console/TenantListCommand.php#L80-L96
txj123/zilf
src/Zilf/Finder/Iterator/FilterIterator.php
FilterIterator.rewind
public function rewind() { if (PHP_VERSION_ID > 50607 || (PHP_VERSION_ID > 50523 && PHP_VERSION_ID < 50600)) { parent::rewind(); return; } $iterator = $this; while ($iterator instanceof \OuterIterator) { $innerIterator = $iterator->getInnerIterator(); if ($innerIterator instanceof RecursiveDirectoryIterator) { // this condition is necessary for iterators to work properly with non-local filesystems like ftp if ($innerIterator->isRewindable()) { $innerIterator->next(); $innerIterator->rewind(); } } elseif ($innerIterator instanceof \FilesystemIterator) { $innerIterator->next(); $innerIterator->rewind(); } $iterator = $innerIterator; } parent::rewind(); }
php
public function rewind() { if (PHP_VERSION_ID > 50607 || (PHP_VERSION_ID > 50523 && PHP_VERSION_ID < 50600)) { parent::rewind(); return; } $iterator = $this; while ($iterator instanceof \OuterIterator) { $innerIterator = $iterator->getInnerIterator(); if ($innerIterator instanceof RecursiveDirectoryIterator) { // this condition is necessary for iterators to work properly with non-local filesystems like ftp if ($innerIterator->isRewindable()) { $innerIterator->next(); $innerIterator->rewind(); } } elseif ($innerIterator instanceof \FilesystemIterator) { $innerIterator->next(); $innerIterator->rewind(); } $iterator = $innerIterator; } parent::rewind(); }
[ "public", "function", "rewind", "(", ")", "{", "if", "(", "PHP_VERSION_ID", ">", "50607", "||", "(", "PHP_VERSION_ID", ">", "50523", "&&", "PHP_VERSION_ID", "<", "50600", ")", ")", "{", "parent", "::", "rewind", "(", ")", ";", "return", ";", "}", "$", ...
This is a workaround for the problem with \FilterIterator leaving inner \FilesystemIterator in wrong state after rewind in some cases. @see FilterIterator::rewind()
[ "This", "is", "a", "workaround", "for", "the", "problem", "with", "\\", "FilterIterator", "leaving", "inner", "\\", "FilesystemIterator", "in", "wrong", "state", "after", "rewind", "in", "some", "cases", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Finder/Iterator/FilterIterator.php#L30-L57
awurth/SlimHelpers
Twig/AssetExtension.php
AssetExtension.asset
public function asset($path) { if (null !== $this->basePath) { return $this->request->getUri()->getBaseUrl().'/'.trim($this->basePath, '/').'/'.$path; } return $this->request->getUri()->getBaseUrl().'/'.$path; }
php
public function asset($path) { if (null !== $this->basePath) { return $this->request->getUri()->getBaseUrl().'/'.trim($this->basePath, '/').'/'.$path; } return $this->request->getUri()->getBaseUrl().'/'.$path; }
[ "public", "function", "asset", "(", "$", "path", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "basePath", ")", "{", "return", "$", "this", "->", "request", "->", "getUri", "(", ")", "->", "getBaseUrl", "(", ")", ".", "'/'", ".", "trim", ...
Gets the path to the asset. @param string $path @return string
[ "Gets", "the", "path", "to", "the", "asset", "." ]
train
https://github.com/awurth/SlimHelpers/blob/abaa0e16e285148f4e4c6b2fd0bb176bce6dac36/Twig/AssetExtension.php#L57-L64
krafthaus/bauhaus
src/KraftHaus/Bauhaus/BauhausServiceProvider.php
BauhausServiceProvider.boot
public function boot() { $this->package('krafthaus/bauhaus'); View::addNamespace('krafthaus/bauhaus', __DIR__ . '/../../views/'); // Register the menu builder App::singleton('krafthaus.bauhaus.menu', function () { return new MenuBuilder; }); // Register the block builder App::singleton('krafthaus.bauhaus.block', function () { return new BlockBuilder; }); require_once __DIR__ . '/../../filters.php'; require_once __DIR__ . '/../../routes.php'; require_once __DIR__ . '/../../composers.php'; }
php
public function boot() { $this->package('krafthaus/bauhaus'); View::addNamespace('krafthaus/bauhaus', __DIR__ . '/../../views/'); // Register the menu builder App::singleton('krafthaus.bauhaus.menu', function () { return new MenuBuilder; }); // Register the block builder App::singleton('krafthaus.bauhaus.block', function () { return new BlockBuilder; }); require_once __DIR__ . '/../../filters.php'; require_once __DIR__ . '/../../routes.php'; require_once __DIR__ . '/../../composers.php'; }
[ "public", "function", "boot", "(", ")", "{", "$", "this", "->", "package", "(", "'krafthaus/bauhaus'", ")", ";", "View", "::", "addNamespace", "(", "'krafthaus/bauhaus'", ",", "__DIR__", ".", "'/../../views/'", ")", ";", "// Register the menu builder", "App", ":...
Boot the package. @access public @return void
[ "Boot", "the", "package", "." ]
train
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/BauhausServiceProvider.php#L40-L58
krafthaus/bauhaus
src/KraftHaus/Bauhaus/BauhausServiceProvider.php
BauhausServiceProvider.register
public function register() { // add the install command to the application $this->app['bauhaus:scaffold'] = $this->app->share(function($app) { return new ScaffoldCommand($app); }); // add the export views command to the application $this->app['bauhaus:views:export'] = $this->app->share(function ($app) { return new ViewsExportCommand($app); }); // add the generate views command to the application $this->app['bauhaus:views:generate'] = $this->app->share(function ($app) { return new ViewsGenerateCommand($app); }); $this->commands('bauhaus:scaffold'); $this->commands('bauhaus:views:export'); $this->commands('bauhaus:views:generate'); }
php
public function register() { // add the install command to the application $this->app['bauhaus:scaffold'] = $this->app->share(function($app) { return new ScaffoldCommand($app); }); // add the export views command to the application $this->app['bauhaus:views:export'] = $this->app->share(function ($app) { return new ViewsExportCommand($app); }); // add the generate views command to the application $this->app['bauhaus:views:generate'] = $this->app->share(function ($app) { return new ViewsGenerateCommand($app); }); $this->commands('bauhaus:scaffold'); $this->commands('bauhaus:views:export'); $this->commands('bauhaus:views:generate'); }
[ "public", "function", "register", "(", ")", "{", "// add the install command to the application", "$", "this", "->", "app", "[", "'bauhaus:scaffold'", "]", "=", "$", "this", "->", "app", "->", "share", "(", "function", "(", "$", "app", ")", "{", "return", "n...
Register the service provider. @access public @return void
[ "Register", "the", "service", "provider", "." ]
train
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/BauhausServiceProvider.php#L66-L86
BusinessMastery/omnipay-mobilpay
src/BusinessMastery/Mobilpay/Message/CompletePurchaseRequest.php
CompletePurchaseRequest.getData
public function getData() { if (! $this->getPrivateKey()) { throw new MissingKeyException("Missing private key path parameter"); } $data = []; $this->responseError = new stdClass(); $this->responseError->code = 0; $this->responseError->type = AbstractRequest::CONFIRM_ERROR_TYPE_NONE; $this->responseError->message = ''; if ($this->getIpnEnvKey() && $this->getIpnData()) { try { $data = AbstractRequest::factoryFromEncrypted( $this->getIpnEnvKey(), $this->getIpnData(), $this->getPrivateKey() ); $this->responseError->message = $data->objPmNotify->getCrc(); $data = json_decode(json_encode($data), true); // extract the transaction status from the IPN message if (isset($data['objPmNotify']['action'])) { $this->action = $data['objPmNotify']['action']; } if (! in_array( $this->action, ['confirmed_pending', 'paid_pending', 'paid', 'confirmed', 'canceled', 'credit'] )) { $this->responseError->type = AbstractRequest::CONFIRM_ERROR_TYPE_PERMANENT; $this->responseError->code = AbstractRequest::ERROR_CONFIRM_INVALID_ACTION; $this->responseError->message = 'mobilpay_refference_action paramaters is invalid'; } } catch (Exception $e) { $this->responseError->type = AbstractRequest::CONFIRM_ERROR_TYPE_TEMPORARY; $this->responseError->code = $e->getCode(); $this->responseError->message = $e->getMessage(); } } else { $this->responseError->type = AbstractRequest::CONFIRM_ERROR_TYPE_PERMANENT; $this->responseError->code = AbstractRequest::ERROR_CONFIRM_INVALID_POST_PARAMETERS; $this->responseError->message = 'mobilpay.ro posted invalid parameters'; } return $data; }
php
public function getData() { if (! $this->getPrivateKey()) { throw new MissingKeyException("Missing private key path parameter"); } $data = []; $this->responseError = new stdClass(); $this->responseError->code = 0; $this->responseError->type = AbstractRequest::CONFIRM_ERROR_TYPE_NONE; $this->responseError->message = ''; if ($this->getIpnEnvKey() && $this->getIpnData()) { try { $data = AbstractRequest::factoryFromEncrypted( $this->getIpnEnvKey(), $this->getIpnData(), $this->getPrivateKey() ); $this->responseError->message = $data->objPmNotify->getCrc(); $data = json_decode(json_encode($data), true); // extract the transaction status from the IPN message if (isset($data['objPmNotify']['action'])) { $this->action = $data['objPmNotify']['action']; } if (! in_array( $this->action, ['confirmed_pending', 'paid_pending', 'paid', 'confirmed', 'canceled', 'credit'] )) { $this->responseError->type = AbstractRequest::CONFIRM_ERROR_TYPE_PERMANENT; $this->responseError->code = AbstractRequest::ERROR_CONFIRM_INVALID_ACTION; $this->responseError->message = 'mobilpay_refference_action paramaters is invalid'; } } catch (Exception $e) { $this->responseError->type = AbstractRequest::CONFIRM_ERROR_TYPE_TEMPORARY; $this->responseError->code = $e->getCode(); $this->responseError->message = $e->getMessage(); } } else { $this->responseError->type = AbstractRequest::CONFIRM_ERROR_TYPE_PERMANENT; $this->responseError->code = AbstractRequest::ERROR_CONFIRM_INVALID_POST_PARAMETERS; $this->responseError->message = 'mobilpay.ro posted invalid parameters'; } return $data; }
[ "public", "function", "getData", "(", ")", "{", "if", "(", "!", "$", "this", "->", "getPrivateKey", "(", ")", ")", "{", "throw", "new", "MissingKeyException", "(", "\"Missing private key path parameter\"", ")", ";", "}", "$", "data", "=", "[", "]", ";", ...
Process IPN request data @return array
[ "Process", "IPN", "request", "data" ]
train
https://github.com/BusinessMastery/omnipay-mobilpay/blob/e9013933e8d12bd69c7def4c88b293f9561ab6e1/src/BusinessMastery/Mobilpay/Message/CompletePurchaseRequest.php#L78-L128
crysalead/sql-dialect
src/Dialect/Sqlite.php
Sqlite._column
protected function _column($field) { extract($field); if ($type === 'float' && $precision) { $use = 'numeric'; } $column = $this->name($name) . ' ' . $this->_formatColumn($use, $length, $precision); $result = [$column]; $result[] = $this->meta('column', $field, ['collate']); if (!empty($serial)) { $result[] = 'NOT NULL'; } else { $result[] = is_bool($null) ? ($null ? 'NULL' : 'NOT NULL') : '' ; if ($default !== null) { if (is_array($default)) { $operator = key($default); $default = current($default); } else { $operator = ':value'; } $states = compact('field'); $result[] = 'DEFAULT ' . $this->format($operator, $default, $states); } } return join(' ', array_filter($result)); }
php
protected function _column($field) { extract($field); if ($type === 'float' && $precision) { $use = 'numeric'; } $column = $this->name($name) . ' ' . $this->_formatColumn($use, $length, $precision); $result = [$column]; $result[] = $this->meta('column', $field, ['collate']); if (!empty($serial)) { $result[] = 'NOT NULL'; } else { $result[] = is_bool($null) ? ($null ? 'NULL' : 'NOT NULL') : '' ; if ($default !== null) { if (is_array($default)) { $operator = key($default); $default = current($default); } else { $operator = ':value'; } $states = compact('field'); $result[] = 'DEFAULT ' . $this->format($operator, $default, $states); } } return join(' ', array_filter($result)); }
[ "protected", "function", "_column", "(", "$", "field", ")", "{", "extract", "(", "$", "field", ")", ";", "if", "(", "$", "type", "===", "'float'", "&&", "$", "precision", ")", "{", "$", "use", "=", "'numeric'", ";", "}", "$", "column", "=", "$", ...
Helper for creating columns @see chaos\source\sql\Dialect::column() @param array $field A field array @return string The SQL column string
[ "Helper", "for", "creating", "columns" ]
train
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Dialect/Sqlite.php#L107-L135
mcustiel/php-simple-di
src/DependencyInjectionService.php
DependencyInjectionService.register
public function register($identifier, callable $loader, $singleton = true) { $this->container->add($identifier, $loader, $singleton); }
php
public function register($identifier, callable $loader, $singleton = true) { $this->container->add($identifier, $loader, $singleton); }
[ "public", "function", "register", "(", "$", "identifier", ",", "callable", "$", "loader", ",", "$", "singleton", "=", "true", ")", "{", "$", "this", "->", "container", "->", "add", "(", "$", "identifier", ",", "$", "loader", ",", "$", "singleton", ")",...
Registers a dependency into the Dependency Injection system @param string $identifier The identifier for this dependency @param callable $loader The loader function for the dependency (to be called when needed) @param string $singleton Whether or not to return always the same instance
[ "Registers", "a", "dependency", "into", "the", "Dependency", "Injection", "system" ]
train
https://github.com/mcustiel/php-simple-di/blob/da0116625d9704185c4a9f01210469266970b265/src/DependencyInjectionService.php#L41-L44
railken/search-query
src/Languages/BoomTree/Resolvers/GroupingResolver.php
GroupingResolver.resolve
public function resolve(NodeContract $node) { $this->resolveParenthesis($node); $this->resolveGrouping($node); return $node; }
php
public function resolve(NodeContract $node) { $this->resolveParenthesis($node); $this->resolveGrouping($node); return $node; }
[ "public", "function", "resolve", "(", "NodeContract", "$", "node", ")", "{", "$", "this", "->", "resolveParenthesis", "(", "$", "node", ")", ";", "$", "this", "->", "resolveGrouping", "(", "$", "node", ")", ";", "return", "$", "node", ";", "}" ]
Resolve node. @param NodeContract $node @return NodeContract
[ "Resolve", "node", "." ]
train
https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Resolvers/GroupingResolver.php#L38-L44
railken/search-query
src/Languages/BoomTree/Resolvers/GroupingResolver.php
GroupingResolver.resolveParenthesis
public function resolveParenthesis(NodeContract $node) { foreach ($node->getChildren() as $child) { $this->resolveParenthesis($child); } if (!$node instanceof Nodes\TextNode) { return; } $value = ''; $positions = []; foreach ($this->regex as $class => $regex) { preg_match($regex, $node->getValue(), $match, PREG_OFFSET_CAPTURE); if ($match) { $new_node = new $class(); $new_node->setValue($match[0][0]); $start = $match[0][1]; $length = strlen($match[0][0]); $nodes = $this->splitNode(Nodes\TextNode::class, $node, $new_node, $start, $start + $length); $this->resolveParenthesis($nodes[count($nodes) - 1]); } } }
php
public function resolveParenthesis(NodeContract $node) { foreach ($node->getChildren() as $child) { $this->resolveParenthesis($child); } if (!$node instanceof Nodes\TextNode) { return; } $value = ''; $positions = []; foreach ($this->regex as $class => $regex) { preg_match($regex, $node->getValue(), $match, PREG_OFFSET_CAPTURE); if ($match) { $new_node = new $class(); $new_node->setValue($match[0][0]); $start = $match[0][1]; $length = strlen($match[0][0]); $nodes = $this->splitNode(Nodes\TextNode::class, $node, $new_node, $start, $start + $length); $this->resolveParenthesis($nodes[count($nodes) - 1]); } } }
[ "public", "function", "resolveParenthesis", "(", "NodeContract", "$", "node", ")", "{", "foreach", "(", "$", "node", "->", "getChildren", "(", ")", "as", "$", "child", ")", "{", "$", "this", "->", "resolveParenthesis", "(", "$", "child", ")", ";", "}", ...
Resolve node parenthesis. @param NodeContract $node
[ "Resolve", "node", "parenthesis", "." ]
train
https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Resolvers/GroupingResolver.php#L51-L79
railken/search-query
src/Languages/BoomTree/Resolvers/GroupingResolver.php
GroupingResolver.resolveGrouping
public function resolveGrouping(NodeContract $node) { if ($node->countChildren() === 0) { return; } foreach ($node->getChildren() as $child) { $this->resolveGrouping($child); } $p = 0; $last_opening = null; foreach ($node->getChildren() as $n => $child) { if ($child instanceof Nodes\GroupOpeningNode) { ++$p; $last_opening = $n; } if ($child instanceof Nodes\GroupClosingNode) { --$p; // A group has found. Close and re-resolve if ($last_opening === null) { throw new Exceptions\QuerySyntaxException('Unexpected closing bracket: '.$node->getRoot()->getValue()); } $new_node = new $this->node(); $children = $node->getChildrenBetweenIndexes((int) $last_opening, $n); $node->removeChildren($children); $new_node->addChildren($children); $new_node->removeChildByIndex(0); $new_node->removeChildByIndex($new_node->countChildren() - 1); $node->addChildBeforeNodeByIndex($new_node, (int) $last_opening); if ($node->getParent() !== null) { $this->resolveGrouping($node->getParent()); } return; } } if ($p > 0) { throw new Exceptions\QuerySyntaxException('Expected closing bracket: '.$node->getRoot()->getValue()); } }
php
public function resolveGrouping(NodeContract $node) { if ($node->countChildren() === 0) { return; } foreach ($node->getChildren() as $child) { $this->resolveGrouping($child); } $p = 0; $last_opening = null; foreach ($node->getChildren() as $n => $child) { if ($child instanceof Nodes\GroupOpeningNode) { ++$p; $last_opening = $n; } if ($child instanceof Nodes\GroupClosingNode) { --$p; // A group has found. Close and re-resolve if ($last_opening === null) { throw new Exceptions\QuerySyntaxException('Unexpected closing bracket: '.$node->getRoot()->getValue()); } $new_node = new $this->node(); $children = $node->getChildrenBetweenIndexes((int) $last_opening, $n); $node->removeChildren($children); $new_node->addChildren($children); $new_node->removeChildByIndex(0); $new_node->removeChildByIndex($new_node->countChildren() - 1); $node->addChildBeforeNodeByIndex($new_node, (int) $last_opening); if ($node->getParent() !== null) { $this->resolveGrouping($node->getParent()); } return; } } if ($p > 0) { throw new Exceptions\QuerySyntaxException('Expected closing bracket: '.$node->getRoot()->getValue()); } }
[ "public", "function", "resolveGrouping", "(", "NodeContract", "$", "node", ")", "{", "if", "(", "$", "node", "->", "countChildren", "(", ")", "===", "0", ")", "{", "return", ";", "}", "foreach", "(", "$", "node", "->", "getChildren", "(", ")", "as", ...
Resolve grouping. @param NodeContract $node
[ "Resolve", "grouping", "." ]
train
https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Resolvers/GroupingResolver.php#L86-L134
txj123/zilf
src/Zilf/HttpFoundation/Cookie.php
Cookie.fromString
public static function fromString($cookie, $decode = false) { $data = array( 'expires' => 0, 'path' => '/', 'domain' => null, 'secure' => false, 'httponly' => true, 'raw' => !$decode, 'samesite' => null, ); foreach (explode(';', $cookie) as $part) { if (false === strpos($part, '=')) { $key = trim($part); $value = true; } else { list($key, $value) = explode('=', trim($part), 2); $key = trim($key); $value = trim($value); } if (!isset($data['name'])) { $data['name'] = $decode ? urldecode($key) : $key; $data['value'] = true === $value ? null : ($decode ? urldecode($value) : $value); continue; } switch ($key = strtolower($key)) { case 'name': case 'value': break; case 'max-age': $data['expires'] = time() + (int) $value; break; default: $data[$key] = $value; break; } } return new static($data['name'], $data['value'], $data['expires'], $data['path'], $data['domain'], $data['secure'], $data['httponly'], $data['raw'], $data['samesite']); }
php
public static function fromString($cookie, $decode = false) { $data = array( 'expires' => 0, 'path' => '/', 'domain' => null, 'secure' => false, 'httponly' => true, 'raw' => !$decode, 'samesite' => null, ); foreach (explode(';', $cookie) as $part) { if (false === strpos($part, '=')) { $key = trim($part); $value = true; } else { list($key, $value) = explode('=', trim($part), 2); $key = trim($key); $value = trim($value); } if (!isset($data['name'])) { $data['name'] = $decode ? urldecode($key) : $key; $data['value'] = true === $value ? null : ($decode ? urldecode($value) : $value); continue; } switch ($key = strtolower($key)) { case 'name': case 'value': break; case 'max-age': $data['expires'] = time() + (int) $value; break; default: $data[$key] = $value; break; } } return new static($data['name'], $data['value'], $data['expires'], $data['path'], $data['domain'], $data['secure'], $data['httponly'], $data['raw'], $data['samesite']); }
[ "public", "static", "function", "fromString", "(", "$", "cookie", ",", "$", "decode", "=", "false", ")", "{", "$", "data", "=", "array", "(", "'expires'", "=>", "0", ",", "'path'", "=>", "'/'", ",", "'domain'", "=>", "null", ",", "'secure'", "=>", "f...
Creates cookie from raw header string. @param string $cookie @param bool $decode @return static
[ "Creates", "cookie", "from", "raw", "header", "string", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/Cookie.php#L42-L81
rmoreas/ShibbolethBundle
Security/ShibbolethUserToken.php
ShibbolethUserToken.getAttribute
public function getAttribute($name) { $value = parent::getAttribute($name); return (is_array($value)) ? $value[0] : $value; }
php
public function getAttribute($name) { $value = parent::getAttribute($name); return (is_array($value)) ? $value[0] : $value; }
[ "public", "function", "getAttribute", "(", "$", "name", ")", "{", "$", "value", "=", "parent", "::", "getAttribute", "(", "$", "name", ")", ";", "return", "(", "is_array", "(", "$", "value", ")", ")", "?", "$", "value", "[", "0", "]", ":", "$", "...
Returns attribute value. If it's a multivalue, the first value is returned
[ "Returns", "attribute", "value", ".", "If", "it", "s", "a", "multivalue", "the", "first", "value", "is", "returned" ]
train
https://github.com/rmoreas/ShibbolethBundle/blob/e3c99bba2a53d9111e9ff3563a9d8f0906e8b69e/Security/ShibbolethUserToken.php#L156-L160
rmoreas/ShibbolethBundle
Security/ShibbolethUserToken.php
ShibbolethUserToken.hasAttributeValue
public function hasAttributeValue($name, $value = null) { if (!$this->hasAttribute($name)) { return false; } return (empty($value))? true : (array_search($value, $this->getArrayAttribute($name)) !== false); }
php
public function hasAttributeValue($name, $value = null) { if (!$this->hasAttribute($name)) { return false; } return (empty($value))? true : (array_search($value, $this->getArrayAttribute($name)) !== false); }
[ "public", "function", "hasAttributeValue", "(", "$", "name", ",", "$", "value", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "hasAttribute", "(", "$", "name", ")", ")", "{", "return", "false", ";", "}", "return", "(", "empty", "(", "$"...
Returns true if attribute exists with given value, or if attribute exists if given value is null.
[ "Returns", "true", "if", "attribute", "exists", "with", "given", "value", "or", "if", "attribute", "exists", "if", "given", "value", "is", "null", "." ]
train
https://github.com/rmoreas/ShibbolethBundle/blob/e3c99bba2a53d9111e9ff3563a9d8f0906e8b69e/Security/ShibbolethUserToken.php#L177-L183
morrislaptop/LaravelFivePackageBridges
src/ConfigServiceProvider.php
ConfigServiceProvider.replaceBoundConfig
protected function replaceBoundConfig() { $configs = $this->app['config']->all(); $this->app->singleton('config', function () use ($configs) { $config = new Repository($configs); return $config; }); }
php
protected function replaceBoundConfig() { $configs = $this->app['config']->all(); $this->app->singleton('config', function () use ($configs) { $config = new Repository($configs); return $config; }); }
[ "protected", "function", "replaceBoundConfig", "(", ")", "{", "$", "configs", "=", "$", "this", "->", "app", "[", "'config'", "]", "->", "all", "(", ")", ";", "$", "this", "->", "app", "->", "singleton", "(", "'config'", ",", "function", "(", ")", "u...
Replace the bound config repo. @return void
[ "Replace", "the", "bound", "config", "repo", "." ]
train
https://github.com/morrislaptop/LaravelFivePackageBridges/blob/9515972cc86544b470989ce22f16e1f09eddf85e/src/ConfigServiceProvider.php#L29-L37
txj123/zilf
src/Zilf/Bus/Dispatcher.php
Dispatcher.dispatchNow
public function dispatchNow($command, $handler = null) { if ($handler || $handler = $this->getCommandHandler($command)) { $callback = function ($command) use ($handler) { return $handler->handle($command); }; } else { $callback = function ($command) { return call_user_func_array([$command, 'handle'], ['kernel'=>Zilf::$container->getShare('consoleKernel')]); }; } return $this->pipeline->send($command)->through($this->pipes)->then($callback); }
php
public function dispatchNow($command, $handler = null) { if ($handler || $handler = $this->getCommandHandler($command)) { $callback = function ($command) use ($handler) { return $handler->handle($command); }; } else { $callback = function ($command) { return call_user_func_array([$command, 'handle'], ['kernel'=>Zilf::$container->getShare('consoleKernel')]); }; } return $this->pipeline->send($command)->through($this->pipes)->then($callback); }
[ "public", "function", "dispatchNow", "(", "$", "command", ",", "$", "handler", "=", "null", ")", "{", "if", "(", "$", "handler", "||", "$", "handler", "=", "$", "this", "->", "getCommandHandler", "(", "$", "command", ")", ")", "{", "$", "callback", "...
Dispatch a command to its appropriate handler in the current process. @param mixed $command @param mixed $handler @return mixed
[ "Dispatch", "a", "command", "to", "its", "appropriate", "handler", "in", "the", "current", "process", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Bus/Dispatcher.php#L78-L91
txj123/zilf
src/Zilf/Console/Application.php
Application.run
public function run(InputInterface $input = null, OutputInterface $output = null) { $exitCode = parent::run($input, $output); return $exitCode; }
php
public function run(InputInterface $input = null, OutputInterface $output = null) { $exitCode = parent::run($input, $output); return $exitCode; }
[ "public", "function", "run", "(", "InputInterface", "$", "input", "=", "null", ",", "OutputInterface", "$", "output", "=", "null", ")", "{", "$", "exitCode", "=", "parent", "::", "run", "(", "$", "input", ",", "$", "output", ")", ";", "return", "$", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Console/Application.php#L64-L69
txj123/zilf
src/Zilf/Console/Application.php
Application.bootstrap
protected function bootstrap() { foreach (static::$bootstrappers as $bootstrapper) { try{ $bootstrapper($this); }catch (\Exception $e){ echo $e->getMessage(); } } }
php
protected function bootstrap() { foreach (static::$bootstrappers as $bootstrapper) { try{ $bootstrapper($this); }catch (\Exception $e){ echo $e->getMessage(); } } }
[ "protected", "function", "bootstrap", "(", ")", "{", "foreach", "(", "static", "::", "$", "bootstrappers", "as", "$", "bootstrapper", ")", "{", "try", "{", "$", "bootstrapper", "(", "$", "this", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e",...
Bootstrap the console application. @return void
[ "Bootstrap", "the", "console", "application", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Console/Application.php#L118-L127
txj123/zilf
src/Zilf/Console/Application.php
Application.call
public function call($command, array $parameters = [], $outputBuffer = null) { if (is_subclass_of($command, SymfonyCommand::class)) { $command = Zilf::$container->build($command)->getName(); } if (!$this->has($command)) { throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $command)); } array_unshift($parameters, $command); $this->lastOutput = $outputBuffer ?: new BufferedOutput; $this->setCatchExceptions(false); $result = $this->run(new ArrayInput($parameters), $this->lastOutput); $this->setCatchExceptions(true); return $result; }
php
public function call($command, array $parameters = [], $outputBuffer = null) { if (is_subclass_of($command, SymfonyCommand::class)) { $command = Zilf::$container->build($command)->getName(); } if (!$this->has($command)) { throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $command)); } array_unshift($parameters, $command); $this->lastOutput = $outputBuffer ?: new BufferedOutput; $this->setCatchExceptions(false); $result = $this->run(new ArrayInput($parameters), $this->lastOutput); $this->setCatchExceptions(true); return $result; }
[ "public", "function", "call", "(", "$", "command", ",", "array", "$", "parameters", "=", "[", "]", ",", "$", "outputBuffer", "=", "null", ")", "{", "if", "(", "is_subclass_of", "(", "$", "command", ",", "SymfonyCommand", "::", "class", ")", ")", "{", ...
Run an Artisan console command by name. @param string $command @param array $parameters @param \Symfony\Component\Console\Output\OutputInterface|null $outputBuffer @return int
[ "Run", "an", "Artisan", "console", "command", "by", "name", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Console/Application.php#L147-L168
dave-redfern/laravel-doctrine-tenancy
src/Entities/Tenant.php
Tenant.updateTenancy
public function updateTenancy(Authenticatable $user, TenantParticipantContract $owner, TenantParticipantContract $creator) { $this->user = $user; $this->tenantOwner = $owner; $this->tenantCreator = $creator; return $this; }
php
public function updateTenancy(Authenticatable $user, TenantParticipantContract $owner, TenantParticipantContract $creator) { $this->user = $user; $this->tenantOwner = $owner; $this->tenantCreator = $creator; return $this; }
[ "public", "function", "updateTenancy", "(", "Authenticatable", "$", "user", ",", "TenantParticipantContract", "$", "owner", ",", "TenantParticipantContract", "$", "creator", ")", "{", "$", "this", "->", "user", "=", "$", "user", ";", "$", "this", "->", "tenant...
Update the tenant details @param Authenticatable $user @param TenantParticipantContract $owner @param TenantParticipantContract $creator @return $this @internal Should not be called normally
[ "Update", "the", "tenant", "details" ]
train
https://github.com/dave-redfern/laravel-doctrine-tenancy/blob/3307fc57ad64d5a4dd5dfb235e19b301661255f9/src/Entities/Tenant.php#L74-L81
opis/orm
src/Traits/SelectTrait.php
SelectTrait.select
public function select($columns = []) { $expr = new ColumnExpression($this->getSQLStatement()); if ($columns instanceof Closure) { $columns($expr); } else { if (!is_array($columns)) { $columns = [$columns]; } $expr->columns($columns); } }
php
public function select($columns = []) { $expr = new ColumnExpression($this->getSQLStatement()); if ($columns instanceof Closure) { $columns($expr); } else { if (!is_array($columns)) { $columns = [$columns]; } $expr->columns($columns); } }
[ "public", "function", "select", "(", "$", "columns", "=", "[", "]", ")", "{", "$", "expr", "=", "new", "ColumnExpression", "(", "$", "this", "->", "getSQLStatement", "(", ")", ")", ";", "if", "(", "$", "columns", "instanceof", "Closure", ")", "{", "$...
@param string|array|Closure $columns
[ "@param", "string|array|Closure", "$columns" ]
train
https://github.com/opis/orm/blob/2723235be55242cd20452b8c9648d4823b7ce8b5/src/Traits/SelectTrait.php#L42-L54
opis/orm
src/Traits/SelectTrait.php
SelectTrait.having
public function having($column, Closure $value = null): self { $this->getHavingStatement()->having($column, $value); return $this; }
php
public function having($column, Closure $value = null): self { $this->getHavingStatement()->having($column, $value); return $this; }
[ "public", "function", "having", "(", "$", "column", ",", "Closure", "$", "value", "=", "null", ")", ":", "self", "{", "$", "this", "->", "getHavingStatement", "(", ")", "->", "having", "(", "$", "column", ",", "$", "value", ")", ";", "return", "$", ...
@param string $column @param Closure $value (optional) @return self|mixed
[ "@param", "string", "$column", "@param", "Closure", "$value", "(", "optional", ")" ]
train
https://github.com/opis/orm/blob/2723235be55242cd20452b8c9648d4823b7ce8b5/src/Traits/SelectTrait.php#L85-L89
opis/orm
src/Traits/SelectTrait.php
SelectTrait.andHaving
public function andHaving($column, Closure $value = null): self { $this->getHavingStatement()->andHaving($column, $value); return $this; }
php
public function andHaving($column, Closure $value = null): self { $this->getHavingStatement()->andHaving($column, $value); return $this; }
[ "public", "function", "andHaving", "(", "$", "column", ",", "Closure", "$", "value", "=", "null", ")", ":", "self", "{", "$", "this", "->", "getHavingStatement", "(", ")", "->", "andHaving", "(", "$", "column", ",", "$", "value", ")", ";", "return", ...
@param string $column @param Closure $value @return self|mixed
[ "@param", "string", "$column", "@param", "Closure", "$value" ]
train
https://github.com/opis/orm/blob/2723235be55242cd20452b8c9648d4823b7ce8b5/src/Traits/SelectTrait.php#L97-L101
opis/orm
src/Traits/SelectTrait.php
SelectTrait.orHaving
public function orHaving($column, Closure $value = null): self { $this->getHavingStatement()->orHaving($column, $value); return $this; }
php
public function orHaving($column, Closure $value = null): self { $this->getHavingStatement()->orHaving($column, $value); return $this; }
[ "public", "function", "orHaving", "(", "$", "column", ",", "Closure", "$", "value", "=", "null", ")", ":", "self", "{", "$", "this", "->", "getHavingStatement", "(", ")", "->", "orHaving", "(", "$", "column", ",", "$", "value", ")", ";", "return", "$...
@param string $column @param Closure $value @return self|mixed
[ "@param", "string", "$column", "@param", "Closure", "$value" ]
train
https://github.com/opis/orm/blob/2723235be55242cd20452b8c9648d4823b7ce8b5/src/Traits/SelectTrait.php#L109-L113
oxygen-cms/core
src/Html/Toolbar/Factory/ButtonToolbarItemFactory.php
ButtonToolbarItemFactory.create
public function create(array $parameters) { $toolbarItem = new ButtonToolbarItem($parameters['label'], $parameters['action']); unset($parameters['label'], $parameters['action']); foreach($parameters as $key => $value) { $toolbarItem->$key = $value; } return $toolbarItem; }
php
public function create(array $parameters) { $toolbarItem = new ButtonToolbarItem($parameters['label'], $parameters['action']); unset($parameters['label'], $parameters['action']); foreach($parameters as $key => $value) { $toolbarItem->$key = $value; } return $toolbarItem; }
[ "public", "function", "create", "(", "array", "$", "parameters", ")", "{", "$", "toolbarItem", "=", "new", "ButtonToolbarItem", "(", "$", "parameters", "[", "'label'", "]", ",", "$", "parameters", "[", "'action'", "]", ")", ";", "unset", "(", "$", "param...
Creates a new toolbar item using the passed parameters. @param array $parameters Passed parameters @return ButtonToolbarItem
[ "Creates", "a", "new", "toolbar", "item", "using", "the", "passed", "parameters", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Html/Toolbar/Factory/ButtonToolbarItemFactory.php#L16-L23
txj123/zilf
src/Zilf/Security/Hashids/Math.php
Math.add
public static function add($a, $b) { if (function_exists('gmp_add')) { return gmp_add($a, $b); } return bcadd($a, $b, 0); }
php
public static function add($a, $b) { if (function_exists('gmp_add')) { return gmp_add($a, $b); } return bcadd($a, $b, 0); }
[ "public", "static", "function", "add", "(", "$", "a", ",", "$", "b", ")", "{", "if", "(", "function_exists", "(", "'gmp_add'", ")", ")", "{", "return", "gmp_add", "(", "$", "a", ",", "$", "b", ")", ";", "}", "return", "bcadd", "(", "$", "a", ",...
Add two arbitrary-length integers. @param string $a @param string $b @return string
[ "Add", "two", "arbitrary", "-", "length", "integers", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Security/Hashids/Math.php#L29-L36
txj123/zilf
src/Zilf/Security/Hashids/Math.php
Math.multiply
public static function multiply($a, $b) { if (function_exists('gmp_mul')) { return gmp_mul($a, $b); } return bcmul($a, $b, 0); }
php
public static function multiply($a, $b) { if (function_exists('gmp_mul')) { return gmp_mul($a, $b); } return bcmul($a, $b, 0); }
[ "public", "static", "function", "multiply", "(", "$", "a", ",", "$", "b", ")", "{", "if", "(", "function_exists", "(", "'gmp_mul'", ")", ")", "{", "return", "gmp_mul", "(", "$", "a", ",", "$", "b", ")", ";", "}", "return", "bcmul", "(", "$", "a",...
Multiply two arbitrary-length integers. @param string $a @param string $b @return string
[ "Multiply", "two", "arbitrary", "-", "length", "integers", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Security/Hashids/Math.php#L46-L53
txj123/zilf
src/Zilf/Security/Hashids/Math.php
Math.divide
public static function divide($a, $b) { if (function_exists('gmp_div_q')) { return gmp_div_q($a, $b); } return bcdiv($a, $b, 0); }
php
public static function divide($a, $b) { if (function_exists('gmp_div_q')) { return gmp_div_q($a, $b); } return bcdiv($a, $b, 0); }
[ "public", "static", "function", "divide", "(", "$", "a", ",", "$", "b", ")", "{", "if", "(", "function_exists", "(", "'gmp_div_q'", ")", ")", "{", "return", "gmp_div_q", "(", "$", "a", ",", "$", "b", ")", ";", "}", "return", "bcdiv", "(", "$", "a...
Divide two arbitrary-length integers. @param string $a @param string $b @return string
[ "Divide", "two", "arbitrary", "-", "length", "integers", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Security/Hashids/Math.php#L63-L70
txj123/zilf
src/Zilf/Security/Hashids/Math.php
Math.mod
public static function mod($n, $d) { if (function_exists('gmp_mod')) { return gmp_mod($n, $d); } return bcmod($n, $d); }
php
public static function mod($n, $d) { if (function_exists('gmp_mod')) { return gmp_mod($n, $d); } return bcmod($n, $d); }
[ "public", "static", "function", "mod", "(", "$", "n", ",", "$", "d", ")", "{", "if", "(", "function_exists", "(", "'gmp_mod'", ")", ")", "{", "return", "gmp_mod", "(", "$", "n", ",", "$", "d", ")", ";", "}", "return", "bcmod", "(", "$", "n", ",...
Compute arbitrary-length integer modulo. @param string $n @param string $d @return string
[ "Compute", "arbitrary", "-", "length", "integer", "modulo", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Security/Hashids/Math.php#L80-L87
txj123/zilf
src/Zilf/Security/Hashids/Math.php
Math.greaterThan
public static function greaterThan($a, $b) { if (function_exists('gmp_cmp')) { return gmp_cmp($a, $b) > 0; } return bccomp($a, $b, 0) > 0; }
php
public static function greaterThan($a, $b) { if (function_exists('gmp_cmp')) { return gmp_cmp($a, $b) > 0; } return bccomp($a, $b, 0) > 0; }
[ "public", "static", "function", "greaterThan", "(", "$", "a", ",", "$", "b", ")", "{", "if", "(", "function_exists", "(", "'gmp_cmp'", ")", ")", "{", "return", "gmp_cmp", "(", "$", "a", ",", "$", "b", ")", ">", "0", ";", "}", "return", "bccomp", ...
Compares two arbitrary-length integers. @param string $a @param string $b @return bool
[ "Compares", "two", "arbitrary", "-", "length", "integers", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Security/Hashids/Math.php#L97-L104
allantatter/laravel-react
src/ReactServiceProvider.php
ReactServiceProvider.register
public function register() { $this->mergeConfigFrom( __DIR__ . '/config/config.php', 'react' ); $this->app['react'] = $this->app->share(function($app) { return $app->make('AllanTatter\React\React'); }); }
php
public function register() { $this->mergeConfigFrom( __DIR__ . '/config/config.php', 'react' ); $this->app['react'] = $this->app->share(function($app) { return $app->make('AllanTatter\React\React'); }); }
[ "public", "function", "register", "(", ")", "{", "$", "this", "->", "mergeConfigFrom", "(", "__DIR__", ".", "'/config/config.php'", ",", "'react'", ")", ";", "$", "this", "->", "app", "[", "'react'", "]", "=", "$", "this", "->", "app", "->", "share", "...
Register the application services. @return void
[ "Register", "the", "application", "services", "." ]
train
https://github.com/allantatter/laravel-react/blob/f16e4a826218c6bd0e009426dd80612cd1f892a2/src/ReactServiceProvider.php#L24-L34
kaurikk/loan-amount-calculator
src/InterestAmountCalculator.php
InterestAmountCalculator.getInterestAmount
public function getInterestAmount(float $presentValue, float $interestRate): float { $interestAmount = ($presentValue * ($interestRate / 100)); return $interestAmount; }
php
public function getInterestAmount(float $presentValue, float $interestRate): float { $interestAmount = ($presentValue * ($interestRate / 100)); return $interestAmount; }
[ "public", "function", "getInterestAmount", "(", "float", "$", "presentValue", ",", "float", "$", "interestRate", ")", ":", "float", "{", "$", "interestAmount", "=", "(", "$", "presentValue", "*", "(", "$", "interestRate", "/", "100", ")", ")", ";", "return...
Calculate interest amount for present value based on interest rate @param float $presentValue @param float $interestRate @return float
[ "Calculate", "interest", "amount", "for", "present", "value", "based", "on", "interest", "rate" ]
train
https://github.com/kaurikk/loan-amount-calculator/blob/841385f16f00d71ac85ba907a98af47686768d83/src/InterestAmountCalculator.php#L16-L20
txj123/zilf
src/Zilf/HttpFoundation/Response.php
Response.prepare
public function prepare(Request $request) { $headers = $this->headers; if ($this->isInformational() || $this->isEmpty()) { $this->setContent(null); $headers->remove('Content-Type'); $headers->remove('Content-Length'); } else { // Content-type based on the Request if (!$headers->has('Content-Type')) { $format = $request->getRequestFormat(); if (null !== $format && $mimeType = $request->getMimeType($format)) { $headers->set('Content-Type', $mimeType); } } // Fix Content-Type $charset = $this->charset ?: 'UTF-8'; if (!$headers->has('Content-Type')) { $headers->set('Content-Type', 'text/html; charset='.$charset); } elseif (0 === stripos($headers->get('Content-Type'), 'text/') && false === stripos($headers->get('Content-Type'), 'charset')) { // add the charset $headers->set('Content-Type', $headers->get('Content-Type').'; charset='.$charset); } // Fix Content-Length if ($headers->has('Transfer-Encoding')) { $headers->remove('Content-Length'); } if ($request->isMethod('HEAD')) { // cf. RFC2616 14.13 $length = $headers->get('Content-Length'); $this->setContent(null); if ($length) { $headers->set('Content-Length', $length); } } } // Fix protocol if ('HTTP/1.0' != $request->server->get('SERVER_PROTOCOL')) { $this->setProtocolVersion('1.1'); } // Check if we need to send extra expire info headers if ('1.0' == $this->getProtocolVersion() && false !== strpos($this->headers->get('Cache-Control'), 'no-cache')) { $this->headers->set('pragma', 'no-cache'); $this->headers->set('expires', -1); } $this->ensureIEOverSSLCompatibility($request); return $this; }
php
public function prepare(Request $request) { $headers = $this->headers; if ($this->isInformational() || $this->isEmpty()) { $this->setContent(null); $headers->remove('Content-Type'); $headers->remove('Content-Length'); } else { // Content-type based on the Request if (!$headers->has('Content-Type')) { $format = $request->getRequestFormat(); if (null !== $format && $mimeType = $request->getMimeType($format)) { $headers->set('Content-Type', $mimeType); } } // Fix Content-Type $charset = $this->charset ?: 'UTF-8'; if (!$headers->has('Content-Type')) { $headers->set('Content-Type', 'text/html; charset='.$charset); } elseif (0 === stripos($headers->get('Content-Type'), 'text/') && false === stripos($headers->get('Content-Type'), 'charset')) { // add the charset $headers->set('Content-Type', $headers->get('Content-Type').'; charset='.$charset); } // Fix Content-Length if ($headers->has('Transfer-Encoding')) { $headers->remove('Content-Length'); } if ($request->isMethod('HEAD')) { // cf. RFC2616 14.13 $length = $headers->get('Content-Length'); $this->setContent(null); if ($length) { $headers->set('Content-Length', $length); } } } // Fix protocol if ('HTTP/1.0' != $request->server->get('SERVER_PROTOCOL')) { $this->setProtocolVersion('1.1'); } // Check if we need to send extra expire info headers if ('1.0' == $this->getProtocolVersion() && false !== strpos($this->headers->get('Cache-Control'), 'no-cache')) { $this->headers->set('pragma', 'no-cache'); $this->headers->set('expires', -1); } $this->ensureIEOverSSLCompatibility($request); return $this; }
[ "public", "function", "prepare", "(", "Request", "$", "request", ")", "{", "$", "headers", "=", "$", "this", "->", "headers", ";", "if", "(", "$", "this", "->", "isInformational", "(", ")", "||", "$", "this", "->", "isEmpty", "(", ")", ")", "{", "$...
Prepares the Response before it is sent to the client. This method tweaks the Response to ensure that it is compliant with RFC 2616. Most of the changes are based on the Request that is "associated" with this Response. @param Request $request A Request instance @return $this
[ "Prepares", "the", "Response", "before", "it", "is", "sent", "to", "the", "client", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/Response.php#L268-L323
txj123/zilf
src/Zilf/HttpFoundation/Response.php
Response.sendHeaders
public function sendHeaders() { // headers have already been sent by the developer if (headers_sent()) { return $this; } /* RFC2616 - 14.18 says all Responses need to have a Date */ if (!$this->headers->has('Date')) { $this->setDate(\DateTime::createFromFormat('U', time())); } // headers foreach ($this->headers->allPreserveCaseWithoutCookies() as $name => $values) { foreach ($values as $value) { header($name.': '.$value, false, $this->statusCode); } } // status header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText), true, $this->statusCode); // cookies foreach ($this->headers->getCookies() as $cookie) { if ($cookie->isRaw()) { setrawcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly()); } else { setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly()); } } return $this; }
php
public function sendHeaders() { // headers have already been sent by the developer if (headers_sent()) { return $this; } /* RFC2616 - 14.18 says all Responses need to have a Date */ if (!$this->headers->has('Date')) { $this->setDate(\DateTime::createFromFormat('U', time())); } // headers foreach ($this->headers->allPreserveCaseWithoutCookies() as $name => $values) { foreach ($values as $value) { header($name.': '.$value, false, $this->statusCode); } } // status header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText), true, $this->statusCode); // cookies foreach ($this->headers->getCookies() as $cookie) { if ($cookie->isRaw()) { setrawcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly()); } else { setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly()); } } return $this; }
[ "public", "function", "sendHeaders", "(", ")", "{", "// headers have already been sent by the developer", "if", "(", "headers_sent", "(", ")", ")", "{", "return", "$", "this", ";", "}", "/* RFC2616 - 14.18 says all Responses need to have a Date */", "if", "(", "!", "$",...
Sends HTTP headers. @return $this
[ "Sends", "HTTP", "headers", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/Response.php#L330-L362
txj123/zilf
src/Zilf/HttpFoundation/Response.php
Response.send
public function send() { $this->sendHeaders(); $this->sendContent(); if (function_exists('fastcgi_finish_request')) { fastcgi_finish_request(); } elseif ('cli' !== PHP_SAPI) { static::closeOutputBuffers(0, true); } return $this; }
php
public function send() { $this->sendHeaders(); $this->sendContent(); if (function_exists('fastcgi_finish_request')) { fastcgi_finish_request(); } elseif ('cli' !== PHP_SAPI) { static::closeOutputBuffers(0, true); } return $this; }
[ "public", "function", "send", "(", ")", "{", "$", "this", "->", "sendHeaders", "(", ")", ";", "$", "this", "->", "sendContent", "(", ")", ";", "if", "(", "function_exists", "(", "'fastcgi_finish_request'", ")", ")", "{", "fastcgi_finish_request", "(", ")",...
Sends HTTP headers and content. @return $this
[ "Sends", "HTTP", "headers", "and", "content", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/Response.php#L381-L393
txj123/zilf
src/Zilf/HttpFoundation/Response.php
Response.getDate
public function getDate() { /* RFC2616 - 14.18 says all Responses need to have a Date. Make sure we provide one even if it the header has been removed in the meantime. */ if (!$this->headers->has('Date')) { $this->setDate(\DateTime::createFromFormat('U', time())); } return $this->headers->getDate('Date'); }
php
public function getDate() { /* RFC2616 - 14.18 says all Responses need to have a Date. Make sure we provide one even if it the header has been removed in the meantime. */ if (!$this->headers->has('Date')) { $this->setDate(\DateTime::createFromFormat('U', time())); } return $this->headers->getDate('Date'); }
[ "public", "function", "getDate", "(", ")", "{", "/*\n RFC2616 - 14.18 says all Responses need to have a Date.\n Make sure we provide one even if it the header\n has been removed in the meantime.\n */", "if", "(", "!", "$", "this", "->", "headers", ...
Returns the Date header as a DateTime instance. @return \DateTime A \DateTime instance @throws \RuntimeException When the header is not parseable @final since version 3.2
[ "Returns", "the", "Date", "header", "as", "a", "DateTime", "instance", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/Response.php#L649-L661
txj123/zilf
src/Zilf/HttpFoundation/Response.php
Response.getAge
public function getAge() { if (null !== $age = $this->headers->get('Age')) { return (int) $age; } return max(time() - $this->getDate()->format('U'), 0); }
php
public function getAge() { if (null !== $age = $this->headers->get('Age')) { return (int) $age; } return max(time() - $this->getDate()->format('U'), 0); }
[ "public", "function", "getAge", "(", ")", "{", "if", "(", "null", "!==", "$", "age", "=", "$", "this", "->", "headers", "->", "get", "(", "'Age'", ")", ")", "{", "return", "(", "int", ")", "$", "age", ";", "}", "return", "max", "(", "time", "("...
Returns the age of the response. @return int The age of the response in seconds @final since version 3.2
[ "Returns", "the", "age", "of", "the", "response", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/Response.php#L687-L694
txj123/zilf
src/Zilf/HttpFoundation/Response.php
Response.ensureIEOverSSLCompatibility
protected function ensureIEOverSSLCompatibility(Request $request) { if (false !== stripos($this->headers->get('Content-Disposition'), 'attachment') && preg_match('/MSIE (.*?);/i', $request->server->get('HTTP_USER_AGENT'), $match) == 1 && true === $request->isSecure()) { if ((int) preg_replace('/(MSIE )(.*?);/', '$2', $match[0]) < 9) { $this->headers->remove('Cache-Control'); } } }
php
protected function ensureIEOverSSLCompatibility(Request $request) { if (false !== stripos($this->headers->get('Content-Disposition'), 'attachment') && preg_match('/MSIE (.*?);/i', $request->server->get('HTTP_USER_AGENT'), $match) == 1 && true === $request->isSecure()) { if ((int) preg_replace('/(MSIE )(.*?);/', '$2', $match[0]) < 9) { $this->headers->remove('Cache-Control'); } } }
[ "protected", "function", "ensureIEOverSSLCompatibility", "(", "Request", "$", "request", ")", "{", "if", "(", "false", "!==", "stripos", "(", "$", "this", "->", "headers", "->", "get", "(", "'Content-Disposition'", ")", ",", "'attachment'", ")", "&&", "preg_ma...
Checks if we need to remove Cache-Control for SSL encrypted downloads when using IE < 9. @see http://support.microsoft.com/kb/323308 @final since version 3.3
[ "Checks", "if", "we", "need", "to", "remove", "Cache", "-", "Control", "for", "SSL", "encrypted", "downloads", "when", "using", "IE", "<", "9", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/Response.php#L1280-L1287
txj123/zilf
src/Zilf/HttpFoundation/Session/Storage/Handler/WriteCheckSessionHandler.php
WriteCheckSessionHandler.read
public function read($sessionId) { $session = $this->wrappedSessionHandler->read($sessionId); $this->readSessions[$sessionId] = $session; return $session; }
php
public function read($sessionId) { $session = $this->wrappedSessionHandler->read($sessionId); $this->readSessions[$sessionId] = $session; return $session; }
[ "public", "function", "read", "(", "$", "sessionId", ")", "{", "$", "session", "=", "$", "this", "->", "wrappedSessionHandler", "->", "read", "(", "$", "sessionId", ")", ";", "$", "this", "->", "readSessions", "[", "$", "sessionId", "]", "=", "$", "ses...
{@inheritdoc}
[ "{" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/Session/Storage/Handler/WriteCheckSessionHandler.php#L71-L78
txj123/zilf
src/Zilf/HttpFoundation/Session/Storage/Handler/WriteCheckSessionHandler.php
WriteCheckSessionHandler.write
public function write($sessionId, $data) { if (isset($this->readSessions[$sessionId]) && $data === $this->readSessions[$sessionId]) { return true; } return $this->wrappedSessionHandler->write($sessionId, $data); }
php
public function write($sessionId, $data) { if (isset($this->readSessions[$sessionId]) && $data === $this->readSessions[$sessionId]) { return true; } return $this->wrappedSessionHandler->write($sessionId, $data); }
[ "public", "function", "write", "(", "$", "sessionId", ",", "$", "data", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "readSessions", "[", "$", "sessionId", "]", ")", "&&", "$", "data", "===", "$", "this", "->", "readSessions", "[", "$", "s...
{@inheritdoc}
[ "{" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/Session/Storage/Handler/WriteCheckSessionHandler.php#L83-L90
txj123/zilf
src/Zilf/Cache/RedisStore.php
RedisStore.put
public function put($key, $value, $minutes) { $this->connection()->setex( $this->prefix.$key, (int) max(1, $minutes * 60), $this->serialize($value) ); }
php
public function put($key, $value, $minutes) { $this->connection()->setex( $this->prefix.$key, (int) max(1, $minutes * 60), $this->serialize($value) ); }
[ "public", "function", "put", "(", "$", "key", ",", "$", "value", ",", "$", "minutes", ")", "{", "$", "this", "->", "connection", "(", ")", "->", "setex", "(", "$", "this", "->", "prefix", ".", "$", "key", ",", "(", "int", ")", "max", "(", "1", ...
Store an item in the cache for a given number of minutes. @param string $key @param mixed $value @param float|int $minutes @return void
[ "Store", "an", "item", "in", "the", "cache", "for", "a", "given", "number", "of", "minutes", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Cache/RedisStore.php#L93-L98
txj123/zilf
src/Zilf/Cache/RedisStore.php
RedisStore.putMany
public function putMany(array $values, $minutes) { $this->connection()->multi(); foreach ($values as $key => $value) { $this->put($key, $value, $minutes); } $this->connection()->exec(); }
php
public function putMany(array $values, $minutes) { $this->connection()->multi(); foreach ($values as $key => $value) { $this->put($key, $value, $minutes); } $this->connection()->exec(); }
[ "public", "function", "putMany", "(", "array", "$", "values", ",", "$", "minutes", ")", "{", "$", "this", "->", "connection", "(", ")", "->", "multi", "(", ")", ";", "foreach", "(", "$", "values", "as", "$", "key", "=>", "$", "value", ")", "{", "...
Store multiple items in the cache for a given number of minutes. @param array $values @param float|int $minutes @return void
[ "Store", "multiple", "items", "in", "the", "cache", "for", "a", "given", "number", "of", "minutes", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Cache/RedisStore.php#L107-L116
txj123/zilf
src/Zilf/Cache/RedisStore.php
RedisStore.add
public function add($key, $value, $minutes) { $lua = "return redis.call('exists',KEYS[1])<1 and redis.call('setex',KEYS[1],ARGV[2],ARGV[1])"; return (bool) $this->connection()->eval( $lua, 1, $this->prefix.$key, $this->serialize($value), (int) max(1, $minutes * 60) ); }
php
public function add($key, $value, $minutes) { $lua = "return redis.call('exists',KEYS[1])<1 and redis.call('setex',KEYS[1],ARGV[2],ARGV[1])"; return (bool) $this->connection()->eval( $lua, 1, $this->prefix.$key, $this->serialize($value), (int) max(1, $minutes * 60) ); }
[ "public", "function", "add", "(", "$", "key", ",", "$", "value", ",", "$", "minutes", ")", "{", "$", "lua", "=", "\"return redis.call('exists',KEYS[1])<1 and redis.call('setex',KEYS[1],ARGV[2],ARGV[1])\"", ";", "return", "(", "bool", ")", "$", "this", "->", "conne...
Store an item in the cache if the key doesn't exist. @param string $key @param mixed $value @param float|int $minutes @return bool
[ "Store", "an", "item", "in", "the", "cache", "if", "the", "key", "doesn", "t", "exist", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Cache/RedisStore.php#L126-L133
txj123/zilf
src/Zilf/HttpFoundation/RequestStack.php
RequestStack.getParentRequest
public function getParentRequest() { $pos = count($this->requests) - 2; if (!isset($this->requests[$pos])) { return; } return $this->requests[$pos]; }
php
public function getParentRequest() { $pos = count($this->requests) - 2; if (!isset($this->requests[$pos])) { return; } return $this->requests[$pos]; }
[ "public", "function", "getParentRequest", "(", ")", "{", "$", "pos", "=", "count", "(", "$", "this", "->", "requests", ")", "-", "2", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "requests", "[", "$", "pos", "]", ")", ")", "{", "return",...
Returns the parent request of the current. Be warned that making your code aware of the parent request might make it un-compatible with other features of your framework like ESI support. If current Request is the master request, it returns null. @return Request|null
[ "Returns", "the", "parent", "request", "of", "the", "current", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/RequestStack.php#L93-L102
txj123/zilf
src/Zilf/Db/pgsql/Schema.php
Schema.findUniqueIndexes
public function findUniqueIndexes($table) { $uniqueIndexes = []; foreach ($this->getUniqueIndexInformation($table) as $row) { if ($this->db->slavePdo->getAttribute(\PDO::ATTR_CASE) === \PDO::CASE_UPPER) { $row = array_change_key_case($row, CASE_LOWER); } $column = $row['columnname']; if (!empty($column) && $column[0] === '"') { // postgres will quote names that are not lowercase-only // https://github.com/Zilfsoft/Zilf2/issues/10613 $column = substr($column, 1, -1); } $uniqueIndexes[$row['indexname']][] = $column; } return $uniqueIndexes; }
php
public function findUniqueIndexes($table) { $uniqueIndexes = []; foreach ($this->getUniqueIndexInformation($table) as $row) { if ($this->db->slavePdo->getAttribute(\PDO::ATTR_CASE) === \PDO::CASE_UPPER) { $row = array_change_key_case($row, CASE_LOWER); } $column = $row['columnname']; if (!empty($column) && $column[0] === '"') { // postgres will quote names that are not lowercase-only // https://github.com/Zilfsoft/Zilf2/issues/10613 $column = substr($column, 1, -1); } $uniqueIndexes[$row['indexname']][] = $column; } return $uniqueIndexes; }
[ "public", "function", "findUniqueIndexes", "(", "$", "table", ")", "{", "$", "uniqueIndexes", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getUniqueIndexInformation", "(", "$", "table", ")", "as", "$", "row", ")", "{", "if", "(", "$", "this"...
Returns all unique indexes for the given table. Each array element is of the following structure: ```php [ 'IndexName1' => ['col1' [, ...]], 'IndexName2' => ['col2' [, ...]], ] ``` @param TableSchema $table the table metadata @return array all unique indexes for the given table.
[ "Returns", "all", "unique", "indexes", "for", "the", "given", "table", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Db/pgsql/Schema.php#L448-L466
txj123/zilf
src/Zilf/Db/pgsql/Schema.php
Schema.loadColumnSchema
protected function loadColumnSchema($info) { /** * @var ColumnSchema $column */ $column = $this->createColumnSchema(); $column->allowNull = $info['is_nullable']; $column->autoIncrement = $info['is_autoinc']; $column->comment = $info['column_comment']; $column->dbType = $info['data_type']; $column->defaultValue = $info['column_default']; $column->enumValues = ($info['enum_values'] !== null) ? explode(',', str_replace(["''"], ["'"], $info['enum_values'])) : null; $column->unsigned = false; // has no meaning in PG $column->isPrimaryKey = $info['is_pkey']; $column->name = $info['column_name']; $column->precision = $info['numeric_precision']; $column->scale = $info['numeric_scale']; $column->size = $info['size'] === null ? null : (int) $info['size']; $column->dimension = (int)$info['dimension']; if (isset($this->typeMap[$column->dbType])) { $column->type = $this->typeMap[$column->dbType]; } else { $column->type = self::TYPE_STRING; } $column->phpType = $this->getColumnPhpType($column); return $column; }
php
protected function loadColumnSchema($info) { /** * @var ColumnSchema $column */ $column = $this->createColumnSchema(); $column->allowNull = $info['is_nullable']; $column->autoIncrement = $info['is_autoinc']; $column->comment = $info['column_comment']; $column->dbType = $info['data_type']; $column->defaultValue = $info['column_default']; $column->enumValues = ($info['enum_values'] !== null) ? explode(',', str_replace(["''"], ["'"], $info['enum_values'])) : null; $column->unsigned = false; // has no meaning in PG $column->isPrimaryKey = $info['is_pkey']; $column->name = $info['column_name']; $column->precision = $info['numeric_precision']; $column->scale = $info['numeric_scale']; $column->size = $info['size'] === null ? null : (int) $info['size']; $column->dimension = (int)$info['dimension']; if (isset($this->typeMap[$column->dbType])) { $column->type = $this->typeMap[$column->dbType]; } else { $column->type = self::TYPE_STRING; } $column->phpType = $this->getColumnPhpType($column); return $column; }
[ "protected", "function", "loadColumnSchema", "(", "$", "info", ")", "{", "/**\n * @var ColumnSchema $column \n*/", "$", "column", "=", "$", "this", "->", "createColumnSchema", "(", ")", ";", "$", "column", "->", "allowNull", "=", "$", "info", "[", "'is_nullable'...
Loads the column information into a [[ColumnSchema]] object. @param array $info column information @return ColumnSchema the column schema object
[ "Loads", "the", "column", "information", "into", "a", "[[", "ColumnSchema", "]]", "object", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Db/pgsql/Schema.php#L585-L612
rifkyekayama/rajaongkir-laravel
src/Endpoints.php
Endpoints.province
public function province($province_id = NULL) { $params = (is_null($province_id)) ? array() : array('id' => $province_id); $rest_client = new RESTClient($this->api_key, 'province', $this->account_type); return $rest_client->get($params); }
php
public function province($province_id = NULL) { $params = (is_null($province_id)) ? array() : array('id' => $province_id); $rest_client = new RESTClient($this->api_key, 'province', $this->account_type); return $rest_client->get($params); }
[ "public", "function", "province", "(", "$", "province_id", "=", "NULL", ")", "{", "$", "params", "=", "(", "is_null", "(", "$", "province_id", ")", ")", "?", "array", "(", ")", ":", "array", "(", "'id'", "=>", "$", "province_id", ")", ";", "$", "re...
Fungsi untuk mendapatkan data propinsi di Indonesia @param integer $province_id ID propinsi, jika NULL tampilkan semua propinsi @return string Response dari cURL, berupa string JSON balasan dari RajaOngkir
[ "Fungsi", "untuk", "mendapatkan", "data", "propinsi", "di", "Indonesia" ]
train
https://github.com/rifkyekayama/rajaongkir-laravel/blob/6eeaf44b7c71b19ab3f26248af987278f240322e/src/Endpoints.php#L26-L30
rifkyekayama/rajaongkir-laravel
src/Endpoints.php
Endpoints.city
public function city($province_id = NULL, $city_id = NULL) { $params = (is_null($province_id)) ? array() : array('province' => $province_id); if (!is_null($city_id)) { $params['id'] = $city_id; } $rest_client = new RESTClient($this->api_key, 'city', $this->account_type); return $rest_client->get($params); }
php
public function city($province_id = NULL, $city_id = NULL) { $params = (is_null($province_id)) ? array() : array('province' => $province_id); if (!is_null($city_id)) { $params['id'] = $city_id; } $rest_client = new RESTClient($this->api_key, 'city', $this->account_type); return $rest_client->get($params); }
[ "public", "function", "city", "(", "$", "province_id", "=", "NULL", ",", "$", "city_id", "=", "NULL", ")", "{", "$", "params", "=", "(", "is_null", "(", "$", "province_id", ")", ")", "?", "array", "(", ")", ":", "array", "(", "'province'", "=>", "$...
Fungsi untuk mendapatkan data kota di Indonesia @param integer $province_id ID propinsi @param integer $city_id ID kota, jika ID propinsi dan kota NULL maka tampilkan semua kota @return string Response dari cURL, berupa string JSON balasan dari RajaOngkir
[ "Fungsi", "untuk", "mendapatkan", "data", "kota", "di", "Indonesia" ]
train
https://github.com/rifkyekayama/rajaongkir-laravel/blob/6eeaf44b7c71b19ab3f26248af987278f240322e/src/Endpoints.php#L38-L45
rifkyekayama/rajaongkir-laravel
src/Endpoints.php
Endpoints.subdistrict
public function subdistrict($city_id = NULL, $subdistrict_id = NULL){ $params = array('city' => $city_id); if(!is_null($subdistrict_id)) { $params['id'] = $subdistrict_id; } $rest_client = new RESTClient($this->api_key, 'subdistrict', $this->account_type); return $rest_client->get($params); }
php
public function subdistrict($city_id = NULL, $subdistrict_id = NULL){ $params = array('city' => $city_id); if(!is_null($subdistrict_id)) { $params['id'] = $subdistrict_id; } $rest_client = new RESTClient($this->api_key, 'subdistrict', $this->account_type); return $rest_client->get($params); }
[ "public", "function", "subdistrict", "(", "$", "city_id", "=", "NULL", ",", "$", "subdistrict_id", "=", "NULL", ")", "{", "$", "params", "=", "array", "(", "'city'", "=>", "$", "city_id", ")", ";", "if", "(", "!", "is_null", "(", "$", "subdistrict_id",...
Fungsi untuk mendapatkan data kecamatan di Indonesia @param integer $city_id ID kota, WAJIB DIISI. @param integer @subdistrict_id ID kecamatan, jika ID kecamatan NULL maka tampilkan semua kecamatan di kota tersebut @return string Response dari cURL berupa string JSON balasan dari RajaOngkir
[ "Fungsi", "untuk", "mendapatkan", "data", "kecamatan", "di", "Indonesia" ]
train
https://github.com/rifkyekayama/rajaongkir-laravel/blob/6eeaf44b7c71b19ab3f26248af987278f240322e/src/Endpoints.php#L53-L60
rifkyekayama/rajaongkir-laravel
src/Endpoints.php
Endpoints.cost
public function cost($origin, $originType, $destination, $destinationType, $weight, $courier) { $params = array( 'origin' => $origin, 'originType' => $originType, 'destination' => $destination, 'destinationType' => $destinationType, 'weight' => $weight, 'courier' => $courier ); $rest_client = new RESTClient($this->api_key, 'cost', $this->account_type); return $rest_client->post($params); }
php
public function cost($origin, $originType, $destination, $destinationType, $weight, $courier) { $params = array( 'origin' => $origin, 'originType' => $originType, 'destination' => $destination, 'destinationType' => $destinationType, 'weight' => $weight, 'courier' => $courier ); $rest_client = new RESTClient($this->api_key, 'cost', $this->account_type); return $rest_client->post($params); }
[ "public", "function", "cost", "(", "$", "origin", ",", "$", "originType", ",", "$", "destination", ",", "$", "destinationType", ",", "$", "weight", ",", "$", "courier", ")", "{", "$", "params", "=", "array", "(", "'origin'", "=>", "$", "origin", ",", ...
Fungsi untuk mendapatkan data ongkos kirim @param integer $origin ID kota asal @param string $originType tipe kota asal 'city' atau 'subdistrict' @param integer $destination ID kota tujuan @param string $destinationType tipe kota tujuan 'city' atau 'subdistrict' @param integer $weight Berat kiriman dalam gram @param string $courier Kode kurir @return string Response dari cURL, berupa string JSON balasan dari RajaOngkir
[ "Fungsi", "untuk", "mendapatkan", "data", "ongkos", "kirim" ]
train
https://github.com/rifkyekayama/rajaongkir-laravel/blob/6eeaf44b7c71b19ab3f26248af987278f240322e/src/Endpoints.php#L72-L83
rifkyekayama/rajaongkir-laravel
src/Endpoints.php
Endpoints.internationalDestination
public function internationalDestination($country_id = NULL) { $params = (is_null($country_id)) ? array() : array('id' => $country_id); $rest_client = new RESTClient($this->api_key, 'internationalDestination', $this->account_type); return $rest_client->get($params); }
php
public function internationalDestination($country_id = NULL) { $params = (is_null($country_id)) ? array() : array('id' => $country_id); $rest_client = new RESTClient($this->api_key, 'internationalDestination', $this->account_type); return $rest_client->get($params); }
[ "public", "function", "internationalDestination", "(", "$", "country_id", "=", "NULL", ")", "{", "$", "params", "=", "(", "is_null", "(", "$", "country_id", ")", ")", "?", "array", "(", ")", ":", "array", "(", "'id'", "=>", "$", "country_id", ")", ";",...
Fungsi untuk mendapatkan daftar/nama negara tujuan pengiriman internasional @param integer ID negara, jika kosong maka akan menampilkan semua negara @return string Response dari cURL, berupa string JSON balasan dari RajaOngkir
[ "Fungsi", "untuk", "mendapatkan", "daftar", "/", "nama", "negara", "tujuan", "pengiriman", "internasional" ]
train
https://github.com/rifkyekayama/rajaongkir-laravel/blob/6eeaf44b7c71b19ab3f26248af987278f240322e/src/Endpoints.php#L107-L111
rifkyekayama/rajaongkir-laravel
src/Endpoints.php
Endpoints.internationalCost
public function internationalCost($origin, $destination, $weight, $courier) { $params = array( 'origin' => $origin, 'destination' => $destination, 'weight' => $weight, 'courier' => $courier ); $rest_client = new RESTClient($this->api_key, 'internationalCost', $this->account_type); return $rest_client->post($params); }
php
public function internationalCost($origin, $destination, $weight, $courier) { $params = array( 'origin' => $origin, 'destination' => $destination, 'weight' => $weight, 'courier' => $courier ); $rest_client = new RESTClient($this->api_key, 'internationalCost', $this->account_type); return $rest_client->post($params); }
[ "public", "function", "internationalCost", "(", "$", "origin", ",", "$", "destination", ",", "$", "weight", ",", "$", "courier", ")", "{", "$", "params", "=", "array", "(", "'origin'", "=>", "$", "origin", ",", "'destination'", "=>", "$", "destination", ...
Fungsi untuk mendapatkan ongkir internasional (EMS) @param integer ID kota asal @param ineteger ID negara tujuan @param integer Berat kiriman dalam gram @param string Kode kurir @return string Response dari cURL, berupa string JSON balasan dari RajaOngkir
[ "Fungsi", "untuk", "mendapatkan", "ongkir", "internasional", "(", "EMS", ")" ]
train
https://github.com/rifkyekayama/rajaongkir-laravel/blob/6eeaf44b7c71b19ab3f26248af987278f240322e/src/Endpoints.php#L122-L131
rifkyekayama/rajaongkir-laravel
src/Endpoints.php
Endpoints.waybill
public function waybill($waybill_number, $courier) { $params = array( 'waybill' => $waybill_number, 'courier' => $courier ); $rest_client = new RESTClient($this->api_key, 'waybill', $this->account_type); return $rest_client->post($params); }
php
public function waybill($waybill_number, $courier) { $params = array( 'waybill' => $waybill_number, 'courier' => $courier ); $rest_client = new RESTClient($this->api_key, 'waybill', $this->account_type); return $rest_client->post($params); }
[ "public", "function", "waybill", "(", "$", "waybill_number", ",", "$", "courier", ")", "{", "$", "params", "=", "array", "(", "'waybill'", "=>", "$", "waybill_number", ",", "'courier'", "=>", "$", "courier", ")", ";", "$", "rest_client", "=", "new", "RES...
Fungsi untuk melacak paket/nomor resi @param string Nomor resi @param string Kode kurir @return string Response dari cURL, berupa string JSON balasan dari RajaOngkir
[ "Fungsi", "untuk", "melacak", "paket", "/", "nomor", "resi" ]
train
https://github.com/rifkyekayama/rajaongkir-laravel/blob/6eeaf44b7c71b19ab3f26248af987278f240322e/src/Endpoints.php#L150-L157
awurth/SlimHelpers
Controller/SentinelTrait.php
SentinelTrait.requireRole
protected function requireRole(Request $request, Response $response, $role, $message = null) { $user = $this->container['sentinel']->getUser(); if (null === $user) { throw $this->unauthorizedException($request, $response); } if (!$user->inRole($role)) { throw $this->accessDeniedException( $request, $response, null === $message ? 'Access denied: User must have role '.$role : $message ); } }
php
protected function requireRole(Request $request, Response $response, $role, $message = null) { $user = $this->container['sentinel']->getUser(); if (null === $user) { throw $this->unauthorizedException($request, $response); } if (!$user->inRole($role)) { throw $this->accessDeniedException( $request, $response, null === $message ? 'Access denied: User must have role '.$role : $message ); } }
[ "protected", "function", "requireRole", "(", "Request", "$", "request", ",", "Response", "$", "response", ",", "$", "role", ",", "$", "message", "=", "null", ")", "{", "$", "user", "=", "$", "this", "->", "container", "[", "'sentinel'", "]", "->", "get...
Throws an AccessDeniedException if the user doesn't have the required role. @param Request $request @param Response $response @param string $role @param string|null $message @throws UnauthorizedException @throws AccessDeniedException
[ "Throws", "an", "AccessDeniedException", "if", "the", "user", "doesn", "t", "have", "the", "required", "role", "." ]
train
https://github.com/awurth/SlimHelpers/blob/abaa0e16e285148f4e4c6b2fd0bb176bce6dac36/Controller/SentinelTrait.php#L25-L40
rifkyekayama/rajaongkir-laravel
src/RESTClient.php
RESTClient.post
public function post($params) { $curl = curl_init(); $header[] = "Content-Type: application/x-www-form-urlencoded"; $header[] = "key: $this->api_key"; $query = http_build_query($params); curl_setopt($curl, CURLOPT_HTTPHEADER, $header); curl_setopt($curl, CURLOPT_URL, $this->api_url . "/" . $this->endpoint); curl_setopt($curl, CURLOPT_POST, TRUE); curl_setopt($curl, CURLOPT_POSTFIELDS, $query); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); $request = curl_exec($curl); $return = ($request === FALSE) ? curl_error($curl) : $request; curl_close($curl); return $return; }
php
public function post($params) { $curl = curl_init(); $header[] = "Content-Type: application/x-www-form-urlencoded"; $header[] = "key: $this->api_key"; $query = http_build_query($params); curl_setopt($curl, CURLOPT_HTTPHEADER, $header); curl_setopt($curl, CURLOPT_URL, $this->api_url . "/" . $this->endpoint); curl_setopt($curl, CURLOPT_POST, TRUE); curl_setopt($curl, CURLOPT_POSTFIELDS, $query); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); $request = curl_exec($curl); $return = ($request === FALSE) ? curl_error($curl) : $request; curl_close($curl); return $return; }
[ "public", "function", "post", "(", "$", "params", ")", "{", "$", "curl", "=", "curl_init", "(", ")", ";", "$", "header", "[", "]", "=", "\"Content-Type: application/x-www-form-urlencoded\"", ";", "$", "header", "[", "]", "=", "\"key: $this->api_key\"", ";", ...
HTTP POST method @param array Parameter yang dikirimkan @return string Response dari cURL
[ "HTTP", "POST", "method" ]
train
https://github.com/rifkyekayama/rajaongkir-laravel/blob/6eeaf44b7c71b19ab3f26248af987278f240322e/src/RESTClient.php#L36-L51
rifkyekayama/rajaongkir-laravel
src/RESTClient.php
RESTClient.get
public function get($params) { $curl = curl_init(); $header[] = "key: $this->api_key"; $query = http_build_query($params); curl_setopt($curl, CURLOPT_HTTPHEADER, $header); curl_setopt($curl, CURLOPT_URL, $this->api_url . "/" . $this->endpoint . "?" . $query); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_ENCODING, ""); curl_setopt($curl, CURLOPT_MAXREDIRS, 10); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "GET"); curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_setopt($curl, CURLOPT_TIMEOUT, 30); $request = curl_exec($curl); $return = ($request === FALSE) ? curl_error($curl) : $request; curl_close($curl); return $return; }
php
public function get($params) { $curl = curl_init(); $header[] = "key: $this->api_key"; $query = http_build_query($params); curl_setopt($curl, CURLOPT_HTTPHEADER, $header); curl_setopt($curl, CURLOPT_URL, $this->api_url . "/" . $this->endpoint . "?" . $query); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($curl, CURLOPT_ENCODING, ""); curl_setopt($curl, CURLOPT_MAXREDIRS, 10); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "GET"); curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_setopt($curl, CURLOPT_TIMEOUT, 30); $request = curl_exec($curl); $return = ($request === FALSE) ? curl_error($curl) : $request; curl_close($curl); return $return; }
[ "public", "function", "get", "(", "$", "params", ")", "{", "$", "curl", "=", "curl_init", "(", ")", ";", "$", "header", "[", "]", "=", "\"key: $this->api_key\"", ";", "$", "query", "=", "http_build_query", "(", "$", "params", ")", ";", "curl_setopt", "...
HTTP GET method @param array Parameter yang dikirimkan @return string Response dari cURL
[ "HTTP", "GET", "method" ]
train
https://github.com/rifkyekayama/rajaongkir-laravel/blob/6eeaf44b7c71b19ab3f26248af987278f240322e/src/RESTClient.php#L59-L76
txj123/zilf
src/Zilf/HttpFoundation/AcceptHeader.php
AcceptHeader.get
public function get($value) { return isset($this->items[$value]) ? $this->items[$value] : null; }
php
public function get($value) { return isset($this->items[$value]) ? $this->items[$value] : null; }
[ "public", "function", "get", "(", "$", "value", ")", "{", "return", "isset", "(", "$", "this", "->", "items", "[", "$", "value", "]", ")", "?", "$", "this", "->", "items", "[", "$", "value", "]", ":", "null", ";", "}" ]
Returns given value's item, if exists. @param string $value @return AcceptHeaderItem|null
[ "Returns", "given", "value", "s", "item", "if", "exists", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/AcceptHeader.php#L98-L101
txj123/zilf
src/Zilf/HttpFoundation/AcceptHeader.php
AcceptHeader.sort
private function sort() { if (!$this->sorted) { uasort( $this->items, function ($a, $b) { $qA = $a->getQuality(); $qB = $b->getQuality(); if ($qA === $qB) { return $a->getIndex() > $b->getIndex() ? 1 : -1; } return $qA > $qB ? -1 : 1; } ); $this->sorted = true; } }
php
private function sort() { if (!$this->sorted) { uasort( $this->items, function ($a, $b) { $qA = $a->getQuality(); $qB = $b->getQuality(); if ($qA === $qB) { return $a->getIndex() > $b->getIndex() ? 1 : -1; } return $qA > $qB ? -1 : 1; } ); $this->sorted = true; } }
[ "private", "function", "sort", "(", ")", "{", "if", "(", "!", "$", "this", "->", "sorted", ")", "{", "uasort", "(", "$", "this", "->", "items", ",", "function", "(", "$", "a", ",", "$", "b", ")", "{", "$", "qA", "=", "$", "a", "->", "getQuali...
Sorts items by descending quality.
[ "Sorts", "items", "by", "descending", "quality", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/AcceptHeader.php#L163-L181
txj123/zilf
src/Zilf/HttpFoundation/ApacheRequest.php
ApacheRequest.prepareBaseUrl
protected function prepareBaseUrl() { $baseUrl = $this->server->get('SCRIPT_NAME'); if (false === strpos($this->server->get('REQUEST_URI'), $baseUrl)) { // assume mod_rewrite return rtrim(dirname($baseUrl), '/\\'); } return $baseUrl; }
php
protected function prepareBaseUrl() { $baseUrl = $this->server->get('SCRIPT_NAME'); if (false === strpos($this->server->get('REQUEST_URI'), $baseUrl)) { // assume mod_rewrite return rtrim(dirname($baseUrl), '/\\'); } return $baseUrl; }
[ "protected", "function", "prepareBaseUrl", "(", ")", "{", "$", "baseUrl", "=", "$", "this", "->", "server", "->", "get", "(", "'SCRIPT_NAME'", ")", ";", "if", "(", "false", "===", "strpos", "(", "$", "this", "->", "server", "->", "get", "(", "'REQUEST_...
{@inheritdoc}
[ "{" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/ApacheRequest.php#L32-L42
Kaishiyoku/laravel-menu
src/Kaishiyoku/Menu/Data/DropdownHeader.php
DropdownHeader.render
public function render($customAttributes = null) { if (MenuHelper::getConfig()->getCustomDropdownHeaderRenderFunction() != null) { return MenuHelper::getConfig()->getCustomDropdownHeaderRenderFunction()($this->title); } return $this->title; }
php
public function render($customAttributes = null) { if (MenuHelper::getConfig()->getCustomDropdownHeaderRenderFunction() != null) { return MenuHelper::getConfig()->getCustomDropdownHeaderRenderFunction()($this->title); } return $this->title; }
[ "public", "function", "render", "(", "$", "customAttributes", "=", "null", ")", "{", "if", "(", "MenuHelper", "::", "getConfig", "(", ")", "->", "getCustomDropdownHeaderRenderFunction", "(", ")", "!=", "null", ")", "{", "return", "MenuHelper", "::", "getConfig...
Get the evaluated contents of the object. @param null|array $customAttributes @return string
[ "Get", "the", "evaluated", "contents", "of", "the", "object", "." ]
train
https://github.com/Kaishiyoku/laravel-menu/blob/0a1aa772f19002d354f0c338e603d98c49d10a7a/src/Kaishiyoku/Menu/Data/DropdownHeader.php#L36-L43
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/Ip.php
Zend_Validate_Ip.isValid
public function isValid($value) { $valueString = (string) $value; $this->_setValue($valueString); if (ip2long($valueString) === false) { $this->_error(); return false; } return true; }
php
public function isValid($value) { $valueString = (string) $value; $this->_setValue($valueString); if (ip2long($valueString) === false) { $this->_error(); return false; } return true; }
[ "public", "function", "isValid", "(", "$", "value", ")", "{", "$", "valueString", "=", "(", "string", ")", "$", "value", ";", "$", "this", "->", "_setValue", "(", "$", "valueString", ")", ";", "if", "(", "ip2long", "(", "$", "valueString", ")", "==="...
Defined by Zend_Validate_Interface Returns true if and only if $value is a valid IP address @param mixed $value @return boolean
[ "Defined", "by", "Zend_Validate_Interface" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/Ip.php#L56-L68
rmoreas/ShibbolethBundle
Service/Shibboleth.php
Shibboleth.getAttributes
public function getAttributes(Request $request) { $attributes = array(); if ($this->isAuthenticated($request)) { foreach ($this->getAttributeDefinitions() as $name => $def) { $value = $this->getAttribute($request, $name); if (null === $value) { //$this->attributes[$name] = array(); } else { if (@$def['charset'] == 'UTF-8') { $value = utf8_decode($value); } $attributes[$name] = (@$def['multivalue'])? explode(';', $value) : $value; } } } return $attributes; }
php
public function getAttributes(Request $request) { $attributes = array(); if ($this->isAuthenticated($request)) { foreach ($this->getAttributeDefinitions() as $name => $def) { $value = $this->getAttribute($request, $name); if (null === $value) { //$this->attributes[$name] = array(); } else { if (@$def['charset'] == 'UTF-8') { $value = utf8_decode($value); } $attributes[$name] = (@$def['multivalue'])? explode(';', $value) : $value; } } } return $attributes; }
[ "public", "function", "getAttributes", "(", "Request", "$", "request", ")", "{", "$", "attributes", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "isAuthenticated", "(", "$", "request", ")", ")", "{", "foreach", "(", "$", "this", "->", "...
Extract Shibboleth attributes from request @param Request $request
[ "Extract", "Shibboleth", "attributes", "from", "request" ]
train
https://github.com/rmoreas/ShibbolethBundle/blob/e3c99bba2a53d9111e9ff3563a9d8f0906e8b69e/Service/Shibboleth.php#L123-L141
rmoreas/ShibbolethBundle
Service/Shibboleth.php
Shibboleth.getLoginUrl
public function getLoginUrl(Request $request, $targetUrl = null) { // convert to absolute URL if not yet absolute. if (empty($targetUrl)) { $targetUrl = $request->getUri(); } return $this->getHandlerURL($request) . $this->getSessionInitiatorPath() . '?target=' . urlencode($targetUrl); }
php
public function getLoginUrl(Request $request, $targetUrl = null) { // convert to absolute URL if not yet absolute. if (empty($targetUrl)) { $targetUrl = $request->getUri(); } return $this->getHandlerURL($request) . $this->getSessionInitiatorPath() . '?target=' . urlencode($targetUrl); }
[ "public", "function", "getLoginUrl", "(", "Request", "$", "request", ",", "$", "targetUrl", "=", "null", ")", "{", "// convert to absolute URL if not yet absolute.", "if", "(", "empty", "(", "$", "targetUrl", ")", ")", "{", "$", "targetUrl", "=", "$", "request...
Returns URL to initiate login session. After successfull login, the user will be redirected to the optional target page. The target can be an absolute or relative URL. @param string $targetUrl URL to redirect to after successfull login. Defaults to the current request URL. @return string The absolute URL to initiate a session
[ "Returns", "URL", "to", "initiate", "login", "session", ".", "After", "successfull", "login", "the", "user", "will", "be", "redirected", "to", "the", "optional", "target", "page", ".", "The", "target", "can", "be", "an", "absolute", "or", "relative", "URL", ...
train
https://github.com/rmoreas/ShibbolethBundle/blob/e3c99bba2a53d9111e9ff3563a9d8f0906e8b69e/Service/Shibboleth.php#L165-L172
rmoreas/ShibbolethBundle
Service/Shibboleth.php
Shibboleth.getLogoutUrl
public function getLogoutUrl(Request $request, $return = null) { $logout_redirect = $this->getAttribute($request, 'logoutURL'); if (!empty($logout_redirect)) { return $this->getHandlerUrl($request) . '/Logout?return='. urlencode($logout_redirect . (empty($return)? '' : '?return='.$return)); } elseif (!empty($return)) { return $this->getHandlerUrl($request) . '/Logout?return='.urlencode($return); } else { return $this->getHandlerUrl($request) . '/Logout'; } }
php
public function getLogoutUrl(Request $request, $return = null) { $logout_redirect = $this->getAttribute($request, 'logoutURL'); if (!empty($logout_redirect)) { return $this->getHandlerUrl($request) . '/Logout?return='. urlencode($logout_redirect . (empty($return)? '' : '?return='.$return)); } elseif (!empty($return)) { return $this->getHandlerUrl($request) . '/Logout?return='.urlencode($return); } else { return $this->getHandlerUrl($request) . '/Logout'; } }
[ "public", "function", "getLogoutUrl", "(", "Request", "$", "request", ",", "$", "return", "=", "null", ")", "{", "$", "logout_redirect", "=", "$", "this", "->", "getAttribute", "(", "$", "request", ",", "'logoutURL'", ")", ";", "if", "(", "!", "empty", ...
Returns URL to invalidate the shibboleth session.
[ "Returns", "URL", "to", "invalidate", "the", "shibboleth", "session", "." ]
train
https://github.com/rmoreas/ShibbolethBundle/blob/e3c99bba2a53d9111e9ff3563a9d8f0906e8b69e/Service/Shibboleth.php#L177-L189
crysalead/sql-dialect
src/Statement/DropTable.php
DropTable.table
public function table($table) { $tables = is_array($table) ? $table : func_get_args(); $this->_parts['table'] = $tables; return $this; }
php
public function table($table) { $tables = is_array($table) ? $table : func_get_args(); $this->_parts['table'] = $tables; return $this; }
[ "public", "function", "table", "(", "$", "table", ")", "{", "$", "tables", "=", "is_array", "(", "$", "table", ")", "?", "$", "table", ":", "func_get_args", "(", ")", ";", "$", "this", "->", "_parts", "[", "'table'", "]", "=", "$", "tables", ";", ...
Set the table name to create. @param string $table The table name. @return object Returns `$this`.
[ "Set", "the", "table", "name", "to", "create", "." ]
train
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/DropTable.php#L41-L46
crysalead/sql-dialect
src/Statement/DropTable.php
DropTable.toString
public function toString() { if (!$this->_parts['table']) { throw new SqlException("Invalid `DROP TABLE` statement, missing `TABLE` clause."); } return 'DROP TABLE' . $this->_buildFlag('IF EXISTS', $this->_parts['ifExists']) . $this->_buildChunk($this->dialect()->names($this->_parts['table'])) . $this->_buildFlag('CASCADE', $this->_parts['cascade']) . $this->_buildFlag('RESTRICT', $this->_parts['restrict']); }
php
public function toString() { if (!$this->_parts['table']) { throw new SqlException("Invalid `DROP TABLE` statement, missing `TABLE` clause."); } return 'DROP TABLE' . $this->_buildFlag('IF EXISTS', $this->_parts['ifExists']) . $this->_buildChunk($this->dialect()->names($this->_parts['table'])) . $this->_buildFlag('CASCADE', $this->_parts['cascade']) . $this->_buildFlag('RESTRICT', $this->_parts['restrict']); }
[ "public", "function", "toString", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_parts", "[", "'table'", "]", ")", "{", "throw", "new", "SqlException", "(", "\"Invalid `DROP TABLE` statement, missing `TABLE` clause.\"", ")", ";", "}", "return", "'DROP TABLE...
Render the SQL statement @return string The generated SQL string.
[ "Render", "the", "SQL", "statement" ]
train
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/DropTable.php#L77-L88
dave-redfern/laravel-doctrine-tenancy
src/Traits/TenantAware.php
TenantAware.importTenancyFrom
public function importTenancyFrom(TenantContract $tenant) { $this->setTenantOwnerId($tenant->getTenantOwnerId()); $this->setTenantCreatorId($tenant->getTenantCreatorId()); return $this; }
php
public function importTenancyFrom(TenantContract $tenant) { $this->setTenantOwnerId($tenant->getTenantOwnerId()); $this->setTenantCreatorId($tenant->getTenantCreatorId()); return $this; }
[ "public", "function", "importTenancyFrom", "(", "TenantContract", "$", "tenant", ")", "{", "$", "this", "->", "setTenantOwnerId", "(", "$", "tenant", "->", "getTenantOwnerId", "(", ")", ")", ";", "$", "this", "->", "setTenantCreatorId", "(", "$", "tenant", "...
@param TenantContract $tenant @return $this
[ "@param", "TenantContract", "$tenant" ]
train
https://github.com/dave-redfern/laravel-doctrine-tenancy/blob/3307fc57ad64d5a4dd5dfb235e19b301661255f9/src/Traits/TenantAware.php#L50-L56
schmunk42/p3extensions
commands/P3RsyncCommand.php
P3RsyncCommand.run
public function run($args) { if (!isset($this->servers)) { echo "No server specified in config!"; exit; } if (!isset($this->aliases)) { echo "No alias defined in config!"; exit; } if (!isset($args[2])) { $this->getHelp(); exit; } $src = $args[0]; $dest = $args[1]; $alias = $args[2]; $file = (isset($args[3])) ? $args[3] : ""; $path = Yii::getPathOfAlias($this->aliases[$alias]); $relativePath = str_replace(Yii::app()->basePath,"",$path); $srcUrl = $this->servers[$src].$relativePath."/".$file; $destUrl = $this->servers[$dest].$relativePath."/".$file; $cmd = "rsync {$this->params} -av ".$srcUrl." ".$destUrl; echo "\n".$cmd."\n\n"; echo "Start rsync of '".$alias."' (".$relativePath."/".$file.") from '".$src."' to '".$dest."'? [Yes|No] "; if(!strncasecmp(trim(fgets(STDIN)),'y',1)) { system($cmd, $output); } else { echo "Skipped.\n"; } }
php
public function run($args) { if (!isset($this->servers)) { echo "No server specified in config!"; exit; } if (!isset($this->aliases)) { echo "No alias defined in config!"; exit; } if (!isset($args[2])) { $this->getHelp(); exit; } $src = $args[0]; $dest = $args[1]; $alias = $args[2]; $file = (isset($args[3])) ? $args[3] : ""; $path = Yii::getPathOfAlias($this->aliases[$alias]); $relativePath = str_replace(Yii::app()->basePath,"",$path); $srcUrl = $this->servers[$src].$relativePath."/".$file; $destUrl = $this->servers[$dest].$relativePath."/".$file; $cmd = "rsync {$this->params} -av ".$srcUrl." ".$destUrl; echo "\n".$cmd."\n\n"; echo "Start rsync of '".$alias."' (".$relativePath."/".$file.") from '".$src."' to '".$dest."'? [Yes|No] "; if(!strncasecmp(trim(fgets(STDIN)),'y',1)) { system($cmd, $output); } else { echo "Skipped.\n"; } }
[ "public", "function", "run", "(", "$", "args", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "servers", ")", ")", "{", "echo", "\"No server specified in config!\"", ";", "exit", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", ...
Syncs from 'server1' to 'server2' the 'alias' @param array $args @return int|void
[ "Syncs", "from", "server1", "to", "server2", "the", "alias", "@param", "array", "$args" ]
train
https://github.com/schmunk42/p3extensions/blob/93999c06fc8e3eadd83983d001df231e46b06838/commands/P3RsyncCommand.php#L68-L102
kiwiz/esquery
src/Scheduler.php
Scheduler.execute
public function execute() { $curr = null; foreach($this->results as $result) { if(!is_null($curr)) { $result->setSource($curr); } $curr = $result->execute(); } return $curr; }
php
public function execute() { $curr = null; foreach($this->results as $result) { if(!is_null($curr)) { $result->setSource($curr); } $curr = $result->execute(); } return $curr; }
[ "public", "function", "execute", "(", ")", "{", "$", "curr", "=", "null", ";", "foreach", "(", "$", "this", "->", "results", "as", "$", "result", ")", "{", "if", "(", "!", "is_null", "(", "$", "curr", ")", ")", "{", "$", "result", "->", "setSourc...
Execute the query. @return Results.
[ "Execute", "the", "query", "." ]
train
https://github.com/kiwiz/esquery/blob/ad05f8d18cb9f1227a82f8d0b9d270882865b31d/src/Scheduler.php#L34-L45
kiwiz/esquery
src/Scheduler.php
Scheduler.generateResults
private function generateResults($settings, $query_list) { if(count($query_list) == 0) { return []; } $query_stack = array_reverse($query_list); $results = []; // Extract global settings. These are applied to all results. $global_settings = []; foreach($settings as $k=>$v) { if(!in_array($k, ['fields', 'map', 'flatten', 'sort', 'count'])) { $global_settings[$k] = $v; } } // Construct result objects from our list of querys and // link them together. do { $curr = new Result(); $curr->setConnProvider($this->conn_provider); $curr->setListProvider($this->list_provider); $curr->setSettings($global_settings); // A source has been set. $source = false; // We've consumed at least one agg. $agg = false; // We've consumed a metrics agg. $metrics = false; // We've consumed all the commands we can. $end = false; while(count($query_stack) && !$end) { $len = count($query_stack); switch($query_stack[$len - 1][0]) { // Transactions are terminal commands. case Token::C_TRANS: // It doesn't make sense for a transaction to be followed by anything. if(count($query_stack) > 1) { throw new Exception('Unexpected command'); } $curr->setPostQuery(array_pop($query_stack)); $end = true; break; // Consume a source command and enable the source bit. case Token::C_SEARCH: case Token::C_JOIN: if(!$source) { $curr->setQuery(array_pop($query_stack)); $source = true; } else { $end = true; } break; // Consume an agg if we've already a source. case Token::C_AGG: if(!$source) { throw new Exception('No source'); } $q = array_pop($query_stack); // Metrics aggs can't have children. switch($q[1]) { case Token::A_MIN: case Token::A_MAX: case Token::A_AVG: case Token::A_SUM: if($metrics) { throw new Exception('Unexpected agg'); } $metrics = true; } $curr->addAgg($q); $agg = true; break; default: throw new Exception('Unknown command type'); } } // Register providers and add to the list. $results[] = $curr; } while(count($query_stack)); $results[count($results) - 1]->setSettings($settings); return $results; }
php
private function generateResults($settings, $query_list) { if(count($query_list) == 0) { return []; } $query_stack = array_reverse($query_list); $results = []; // Extract global settings. These are applied to all results. $global_settings = []; foreach($settings as $k=>$v) { if(!in_array($k, ['fields', 'map', 'flatten', 'sort', 'count'])) { $global_settings[$k] = $v; } } // Construct result objects from our list of querys and // link them together. do { $curr = new Result(); $curr->setConnProvider($this->conn_provider); $curr->setListProvider($this->list_provider); $curr->setSettings($global_settings); // A source has been set. $source = false; // We've consumed at least one agg. $agg = false; // We've consumed a metrics agg. $metrics = false; // We've consumed all the commands we can. $end = false; while(count($query_stack) && !$end) { $len = count($query_stack); switch($query_stack[$len - 1][0]) { // Transactions are terminal commands. case Token::C_TRANS: // It doesn't make sense for a transaction to be followed by anything. if(count($query_stack) > 1) { throw new Exception('Unexpected command'); } $curr->setPostQuery(array_pop($query_stack)); $end = true; break; // Consume a source command and enable the source bit. case Token::C_SEARCH: case Token::C_JOIN: if(!$source) { $curr->setQuery(array_pop($query_stack)); $source = true; } else { $end = true; } break; // Consume an agg if we've already a source. case Token::C_AGG: if(!$source) { throw new Exception('No source'); } $q = array_pop($query_stack); // Metrics aggs can't have children. switch($q[1]) { case Token::A_MIN: case Token::A_MAX: case Token::A_AVG: case Token::A_SUM: if($metrics) { throw new Exception('Unexpected agg'); } $metrics = true; } $curr->addAgg($q); $agg = true; break; default: throw new Exception('Unknown command type'); } } // Register providers and add to the list. $results[] = $curr; } while(count($query_stack)); $results[count($results) - 1]->setSettings($settings); return $results; }
[ "private", "function", "generateResults", "(", "$", "settings", ",", "$", "query_list", ")", "{", "if", "(", "count", "(", "$", "query_list", ")", "==", "0", ")", "{", "return", "[", "]", ";", "}", "$", "query_stack", "=", "array_reverse", "(", "$", ...
Generate result objects for processing. @param array $settings Query settings. @param array $query_list List of queries. @return An array of result objects.
[ "Generate", "result", "objects", "for", "processing", "." ]
train
https://github.com/kiwiz/esquery/blob/ad05f8d18cb9f1227a82f8d0b9d270882865b31d/src/Scheduler.php#L53-L141
krafthaus/bauhaus
src/KraftHaus/Bauhaus/Export/Format/XmlFormat.php
XmlFormat.export
public function export() { $result = []; foreach ($this->getListBuilder()->getResult() as $item) { foreach ($item->getFields() as $field) { $value = $field->getValue(); if (!is_string($value)) { $value = $value->toArray(); } $result[$item->getIdentifier()][$field->getName()] = $value; } } $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><response/>'); $this->arrayToXml($result, $xml); return $this->createResponse($xml->asXML()); }
php
public function export() { $result = []; foreach ($this->getListBuilder()->getResult() as $item) { foreach ($item->getFields() as $field) { $value = $field->getValue(); if (!is_string($value)) { $value = $value->toArray(); } $result[$item->getIdentifier()][$field->getName()] = $value; } } $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><response/>'); $this->arrayToXml($result, $xml); return $this->createResponse($xml->asXML()); }
[ "public", "function", "export", "(", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getListBuilder", "(", ")", "->", "getResult", "(", ")", "as", "$", "item", ")", "{", "foreach", "(", "$", "item", "->", "getFields...
Create the json response. @access public @return JsonResponse|mixed
[ "Create", "the", "json", "response", "." ]
train
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Export/Format/XmlFormat.php#L43-L62
krafthaus/bauhaus
src/KraftHaus/Bauhaus/Export/Format/XmlFormat.php
XmlFormat.arrayToXml
protected function arrayToXml($result, &$xml) { foreach ($result as $key => $value) { if (is_array($value)) { if (!is_numeric($key)) { $subnode = $xml->addChild((string) $key); } else { $subnode = $xml->addChild('item_' . $key); } $this->arrayToXml($value, $subnode); } else { $xml->addChild($key, $value); } } }
php
protected function arrayToXml($result, &$xml) { foreach ($result as $key => $value) { if (is_array($value)) { if (!is_numeric($key)) { $subnode = $xml->addChild((string) $key); } else { $subnode = $xml->addChild('item_' . $key); } $this->arrayToXml($value, $subnode); } else { $xml->addChild($key, $value); } } }
[ "protected", "function", "arrayToXml", "(", "$", "result", ",", "&", "$", "xml", ")", "{", "foreach", "(", "$", "result", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "if", "(", "!", "...
Create an xml representatation from an array. @param array $result @param SimpleXMLElement $xml @access public @return void
[ "Create", "an", "xml", "representatation", "from", "an", "array", "." ]
train
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Export/Format/XmlFormat.php#L73-L87
txj123/zilf
src/Zilf/System/Bootstrap/RegisterProviders.php
RegisterProviders.bootstrap
public function bootstrap() { $providers = Zilf::$container->getShare('config')->get('services'); foreach ($providers as $provider) { $instance = $this->createProvider($provider); $instance->register(); } }
php
public function bootstrap() { $providers = Zilf::$container->getShare('config')->get('services'); foreach ($providers as $provider) { $instance = $this->createProvider($provider); $instance->register(); } }
[ "public", "function", "bootstrap", "(", ")", "{", "$", "providers", "=", "Zilf", "::", "$", "container", "->", "getShare", "(", "'config'", ")", "->", "get", "(", "'services'", ")", ";", "foreach", "(", "$", "providers", "as", "$", "provider", ")", "{"...
Bootstrap the given application. @return void
[ "Bootstrap", "the", "given", "application", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/System/Bootstrap/RegisterProviders.php#L14-L22
txj123/zilf
src/Zilf/Db/base/Model.php
Model.onUnsafeAttribute
public function onUnsafeAttribute($name, $value) { if (Zilf::$app->is_debug) { Log::debug("Failed to set unsafe attribute '$name' in '" . get_class($this) . "'.".__METHOD__); } }
php
public function onUnsafeAttribute($name, $value) { if (Zilf::$app->is_debug) { Log::debug("Failed to set unsafe attribute '$name' in '" . get_class($this) . "'.".__METHOD__); } }
[ "public", "function", "onUnsafeAttribute", "(", "$", "name", ",", "$", "value", ")", "{", "if", "(", "Zilf", "::", "$", "app", "->", "is_debug", ")", "{", "Log", "::", "debug", "(", "\"Failed to set unsafe attribute '$name' in '\"", ".", "get_class", "(", "$...
This method is invoked when an unsafe attribute is being massively assigned. The default implementation will log a warning message if Zilf_DEBUG is on. It does nothing otherwise. @param string $name the unsafe attribute name @param mixed $value the attribute value
[ "This", "method", "is", "invoked", "when", "an", "unsafe", "attribute", "is", "being", "massively", "assigned", ".", "The", "default", "implementation", "will", "log", "a", "warning", "message", "if", "Zilf_DEBUG", "is", "on", ".", "It", "does", "nothing", "...
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Db/base/Model.php#L781-L786