repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
ruxon/framework
src/Sms/BaseSmsSms.class.php
BaseSmsSms.cost
public function cost($to, $text) { $url = self::HOST . self::COST; $this->id = null; $params = $this->get_default_params(); $params['to'] = $to; $params['text'] = $text; $result = $this->request($url, $params); $result = explode("\n", $result); return array( 'code' => $result[0], 'price' => $result[1], 'number' => $result[2] ); }
php
public function cost($to, $text) { $url = self::HOST . self::COST; $this->id = null; $params = $this->get_default_params(); $params['to'] = $to; $params['text'] = $text; $result = $this->request($url, $params); $result = explode("\n", $result); return array( 'code' => $result[0], 'price' => $result[1], 'number' => $result[2] ); }
[ "public", "function", "cost", "(", "$", "to", ",", "$", "text", ")", "{", "$", "url", "=", "self", "::", "HOST", ".", "self", "::", "COST", ";", "$", "this", "->", "id", "=", "null", ";", "$", "params", "=", "$", "this", "->", "get_default_params...
Get message cost @param type $to @param type $text @return type
[ "Get", "message", "cost" ]
d6c9a48df41c8564ee1b0455cd09fbe789e6b086
https://github.com/ruxon/framework/blob/d6c9a48df41c8564ee1b0455cd09fbe789e6b086/src/Sms/BaseSmsSms.class.php#L139-L156
train
ruxon/framework
src/Sms/BaseSmsSms.class.php
BaseSmsSms.senders
public function senders() { $url = self::HOST . self::SENDERS; $params = $this->get_default_params(); $result = $this->request($url, $params); $result = explode("\n", rtrim($result)); $response = array( 'code' => $result[0], 'senders' => $result ); unset($response['senders'][0]); $response['senders'] = array_values($response['senders']); return $response; }
php
public function senders() { $url = self::HOST . self::SENDERS; $params = $this->get_default_params(); $result = $this->request($url, $params); $result = explode("\n", rtrim($result)); $response = array( 'code' => $result[0], 'senders' => $result ); unset($response['senders'][0]); $response['senders'] = array_values($response['senders']); return $response; }
[ "public", "function", "senders", "(", ")", "{", "$", "url", "=", "self", "::", "HOST", ".", "self", "::", "SENDERS", ";", "$", "params", "=", "$", "this", "->", "get_default_params", "(", ")", ";", "$", "result", "=", "$", "this", "->", "request", ...
Get my senders list @return array
[ "Get", "my", "senders", "list" ]
d6c9a48df41c8564ee1b0455cd09fbe789e6b086
https://github.com/ruxon/framework/blob/d6c9a48df41c8564ee1b0455cd09fbe789e6b086/src/Sms/BaseSmsSms.class.php#L163-L178
train
ruxon/framework
src/Sms/BaseSmsSms.class.php
BaseSmsSms.check
public function check() { $url = self::HOST . self::CHECK; $params = $this->get_default_params(); $result = $this->request($url, $params); return $result; }
php
public function check() { $url = self::HOST . self::CHECK; $params = $this->get_default_params(); $result = $this->request($url, $params); return $result; }
[ "public", "function", "check", "(", ")", "{", "$", "url", "=", "self", "::", "HOST", ".", "self", "::", "CHECK", ";", "$", "params", "=", "$", "this", "->", "get_default_params", "(", ")", ";", "$", "result", "=", "$", "this", "->", "request", "(",...
Check user auth @return type
[ "Check", "user", "auth" ]
d6c9a48df41c8564ee1b0455cd09fbe789e6b086
https://github.com/ruxon/framework/blob/d6c9a48df41c8564ee1b0455cd09fbe789e6b086/src/Sms/BaseSmsSms.class.php#L185-L192
train
frostnode/frostnode-cms
modules/Page/Http/Controllers/PageController.php
PageController.trashed
public function trashed(Request $request) { // Set roles that have access $request->user()->authorizeRoles(['admin', 'editor']); $pages = Page::onlyTrashed() ->orderBy('updated_at', 'desc') ->orderBy('created_at', 'desc') ->with('pagetype') ->paginate(self::PAGINATION_ITEMS); return view('page::pages.trashed', ['pages' => $pages]); }
php
public function trashed(Request $request) { // Set roles that have access $request->user()->authorizeRoles(['admin', 'editor']); $pages = Page::onlyTrashed() ->orderBy('updated_at', 'desc') ->orderBy('created_at', 'desc') ->with('pagetype') ->paginate(self::PAGINATION_ITEMS); return view('page::pages.trashed', ['pages' => $pages]); }
[ "public", "function", "trashed", "(", "Request", "$", "request", ")", "{", "// Set roles that have access", "$", "request", "->", "user", "(", ")", "->", "authorizeRoles", "(", "[", "'admin'", ",", "'editor'", "]", ")", ";", "$", "pages", "=", "Page", "::"...
Display a listing of trashed resources. @param Request $request @return Response @todo: This should be merged into index method
[ "Display", "a", "listing", "of", "trashed", "resources", "." ]
486db24bb8ebd73dcc1ef71f79509817d23fbf45
https://github.com/frostnode/frostnode-cms/blob/486db24bb8ebd73dcc1ef71f79509817d23fbf45/modules/Page/Http/Controllers/PageController.php#L85-L97
train
frostnode/frostnode-cms
modules/Page/Http/Controllers/PageController.php
PageController.select
public function select(Request $request) { // Set roles that have access $request->user()->authorizeRoles(['admin', 'editor']); // Get all pagetypes $pagetypes = PageType::all(); return view('page::pages.select', ['pagetypes' => $pagetypes]); }
php
public function select(Request $request) { // Set roles that have access $request->user()->authorizeRoles(['admin', 'editor']); // Get all pagetypes $pagetypes = PageType::all(); return view('page::pages.select', ['pagetypes' => $pagetypes]); }
[ "public", "function", "select", "(", "Request", "$", "request", ")", "{", "// Set roles that have access", "$", "request", "->", "user", "(", ")", "->", "authorizeRoles", "(", "[", "'admin'", ",", "'editor'", "]", ")", ";", "// Get all pagetypes", "$", "pagety...
Show the form for selecting a new resource. @param Request $request @return Response
[ "Show", "the", "form", "for", "selecting", "a", "new", "resource", "." ]
486db24bb8ebd73dcc1ef71f79509817d23fbf45
https://github.com/frostnode/frostnode-cms/blob/486db24bb8ebd73dcc1ef71f79509817d23fbf45/modules/Page/Http/Controllers/PageController.php#L104-L112
train
frostnode/frostnode-cms
modules/Page/Http/Controllers/PageController.php
PageController.delete
public function delete(Request $request, $page) { // Set roles that have access $request->user()->authorizeRoles(['admin', 'editor']); $page = Page::withTrashed()->findOrFail($page); return view('page::pages.delete', ['page' => $page]); }
php
public function delete(Request $request, $page) { // Set roles that have access $request->user()->authorizeRoles(['admin', 'editor']); $page = Page::withTrashed()->findOrFail($page); return view('page::pages.delete', ['page' => $page]); }
[ "public", "function", "delete", "(", "Request", "$", "request", ",", "$", "page", ")", "{", "// Set roles that have access", "$", "request", "->", "user", "(", ")", "->", "authorizeRoles", "(", "[", "'admin'", ",", "'editor'", "]", ")", ";", "$", "page", ...
Display a delete page. @param Request $request @param $page @return View
[ "Display", "a", "delete", "page", "." ]
486db24bb8ebd73dcc1ef71f79509817d23fbf45
https://github.com/frostnode/frostnode-cms/blob/486db24bb8ebd73dcc1ef71f79509817d23fbf45/modules/Page/Http/Controllers/PageController.php#L310-L317
train
xobotyi/dotarray
src/A.php
A.splitPath
public static function splitPath(string $path, bool $safe = null): array { if ($path === '') { return []; } $safe = ($safe === null ? self::$safeSeparationMode : $safe); if ($safe) { $segments = preg_split('~\\\\' . self::$separator . '(*SKIP)(*F)|\.~s', $path, -1, PREG_SPLIT_NO_EMPTY); if ($segments === false) { // actually this code can't be covered with tests, because i don't know how to make preg_split() // return a FALSE value but handling it in case some one will %) trigger_error('Path splitting failed, received path: ' . $path); $segments = []; } foreach ($segments as &$segment) { $segment = stripslashes($segment); } return $segments; } return explode(self::$separator, $path); }
php
public static function splitPath(string $path, bool $safe = null): array { if ($path === '') { return []; } $safe = ($safe === null ? self::$safeSeparationMode : $safe); if ($safe) { $segments = preg_split('~\\\\' . self::$separator . '(*SKIP)(*F)|\.~s', $path, -1, PREG_SPLIT_NO_EMPTY); if ($segments === false) { // actually this code can't be covered with tests, because i don't know how to make preg_split() // return a FALSE value but handling it in case some one will %) trigger_error('Path splitting failed, received path: ' . $path); $segments = []; } foreach ($segments as &$segment) { $segment = stripslashes($segment); } return $segments; } return explode(self::$separator, $path); }
[ "public", "static", "function", "splitPath", "(", "string", "$", "path", ",", "bool", "$", "safe", "=", "null", ")", ":", "array", "{", "if", "(", "$", "path", "===", "''", ")", "{", "return", "[", "]", ";", "}", "$", "safe", "=", "(", "$", "sa...
Split given string to it's segments according to dot notation. Empty segments will be ignored. Supports escaping. @param string $path @param bool $safe @return array
[ "Split", "given", "string", "to", "it", "s", "segments", "according", "to", "dot", "notation", ".", "Empty", "segments", "will", "be", "ignored", ".", "Supports", "escaping", "." ]
5781c1e2752fa6be7bb88b575b901a00788bfe70
https://github.com/xobotyi/dotarray/blob/5781c1e2752fa6be7bb88b575b901a00788bfe70/src/A.php#L191-L218
train
xobotyi/dotarray
src/A.php
A.set
public static function set(array $array, ...$args): array { if (empty($args)) { throw new \ArgumentCountError('Too few arguments to function xobotyi\A::set(), 1 passed, at least 2 expected'); } if (is_string($args[0]) || is_numeric($args[0])) { if (!isset($args[1]) && !\array_key_exists(1, $args)) { throw new \ArgumentCountError('Too few arguments to function xobotyi\A::set(), 2 passed, at least 3 expected when second is string'); } $args = [$args[0] => $args[1]]; } else if (\is_array($args[0])) { $args = $args[0]; } else { throw new \TypeError("Argument 2 passed to xobotyi\A::set() must be of the type array or string, " . gettype($args[0]) . " given"); } foreach ($args as $path => &$value) { if ($path === '') { continue; } $path = self::splitPath($path); if (empty($path)) { continue; } $scope = &$array; for ($i = 0; $i < count($path) - 1; $i++) { if (!isset($scope[$path[$i]]) || !\is_array($scope[$path[$i]])) { $scope[$path[$i]] = []; } $scope = &$scope[$path[$i]]; } $scope[$path[$i]] = $value; } return $array; }
php
public static function set(array $array, ...$args): array { if (empty($args)) { throw new \ArgumentCountError('Too few arguments to function xobotyi\A::set(), 1 passed, at least 2 expected'); } if (is_string($args[0]) || is_numeric($args[0])) { if (!isset($args[1]) && !\array_key_exists(1, $args)) { throw new \ArgumentCountError('Too few arguments to function xobotyi\A::set(), 2 passed, at least 3 expected when second is string'); } $args = [$args[0] => $args[1]]; } else if (\is_array($args[0])) { $args = $args[0]; } else { throw new \TypeError("Argument 2 passed to xobotyi\A::set() must be of the type array or string, " . gettype($args[0]) . " given"); } foreach ($args as $path => &$value) { if ($path === '') { continue; } $path = self::splitPath($path); if (empty($path)) { continue; } $scope = &$array; for ($i = 0; $i < count($path) - 1; $i++) { if (!isset($scope[$path[$i]]) || !\is_array($scope[$path[$i]])) { $scope[$path[$i]] = []; } $scope = &$scope[$path[$i]]; } $scope[$path[$i]] = $value; } return $array; }
[ "public", "static", "function", "set", "(", "array", "$", "array", ",", "...", "$", "args", ")", ":", "array", "{", "if", "(", "empty", "(", "$", "args", ")", ")", "{", "throw", "new", "\\", "ArgumentCountError", "(", "'Too few arguments to function xoboty...
Set the value passed with 3'rd argument on the path passed with 2'nd argument. If 2'nd argument is array, it's keys will be used as paths and items as values. Empty paths will be processed as non-existent. @param array $array @param array ...$args @return array @throws \ArgumentCountError @throws \TypeError
[ "Set", "the", "value", "passed", "with", "3", "rd", "argument", "on", "the", "path", "passed", "with", "2", "nd", "argument", ".", "If", "2", "nd", "argument", "is", "array", "it", "s", "keys", "will", "be", "used", "as", "paths", "and", "items", "as...
5781c1e2752fa6be7bb88b575b901a00788bfe70
https://github.com/xobotyi/dotarray/blob/5781c1e2752fa6be7bb88b575b901a00788bfe70/src/A.php#L419-L462
train
leedave/resource-mysql
src/Tools/Update.php
Update.updateDb
public function updateDb() { $this->createUpdateTableIfNotExists(); $this->getProcessedFiles(); $path = leedch_resourceMysqlUpdateFolder; $files = $this->findNewFiles($path); $this->processNewFiles($files); }
php
public function updateDb() { $this->createUpdateTableIfNotExists(); $this->getProcessedFiles(); $path = leedch_resourceMysqlUpdateFolder; $files = $this->findNewFiles($path); $this->processNewFiles($files); }
[ "public", "function", "updateDb", "(", ")", "{", "$", "this", "->", "createUpdateTableIfNotExists", "(", ")", ";", "$", "this", "->", "getProcessedFiles", "(", ")", ";", "$", "path", "=", "leedch_resourceMysqlUpdateFolder", ";", "$", "files", "=", "$", "this...
This method is triggered in Bash to process DB Update Files
[ "This", "method", "is", "triggered", "in", "Bash", "to", "process", "DB", "Update", "Files" ]
68305dac50b1b956f08f41267d0b2912850d8232
https://github.com/leedave/resource-mysql/blob/68305dac50b1b956f08f41267d0b2912850d8232/src/Tools/Update.php#L32-L41
train
leedave/resource-mysql
src/Tools/Update.php
Update.processNewFiles
protected function processNewFiles(array $files) { foreach ($files as $file) { if (!file_exists($file)) { //This is bad throw new Exception('Cant find File: '.$file); } include $file; if (!isset($arrUpdate)) { throw new Exception('Array $arrUpdate does not exist in '.$file); } try { $this->processArray($arrUpdate); $this->addFileToProcessedList($file); } catch (Exception $ex) { echo $ex->getMessage(); } unset($arrUpdate); } }
php
protected function processNewFiles(array $files) { foreach ($files as $file) { if (!file_exists($file)) { //This is bad throw new Exception('Cant find File: '.$file); } include $file; if (!isset($arrUpdate)) { throw new Exception('Array $arrUpdate does not exist in '.$file); } try { $this->processArray($arrUpdate); $this->addFileToProcessedList($file); } catch (Exception $ex) { echo $ex->getMessage(); } unset($arrUpdate); } }
[ "protected", "function", "processNewFiles", "(", "array", "$", "files", ")", "{", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "if", "(", "!", "file_exists", "(", "$", "file", ")", ")", "{", "//This is bad", "throw", "new", "Exception", "...
Reads the Update Files and triggers the Update @param array $files @throws Exception
[ "Reads", "the", "Update", "Files", "and", "triggers", "the", "Update" ]
68305dac50b1b956f08f41267d0b2912850d8232
https://github.com/leedave/resource-mysql/blob/68305dac50b1b956f08f41267d0b2912850d8232/src/Tools/Update.php#L59-L81
train
leedave/resource-mysql
src/Tools/Update.php
Update.addFileToProcessedList
protected function addFileToProcessedList(string $filePath) { $arrFile = explode(DIRECTORY_SEPARATOR, $filePath); $fileName = array_pop($arrFile); $folder = implode(DIRECTORY_SEPARATOR, $arrFile).DIRECTORY_SEPARATOR; $tmp = new Update(); $tmp->name = $fileName; $tmp->folder = $folder; $tmp->createDate = strftime("%Y-%m-%d %H:%M:%S"); $tmp->save(); echo "Processed: ".$fileName."\n"; unset($tmp); }
php
protected function addFileToProcessedList(string $filePath) { $arrFile = explode(DIRECTORY_SEPARATOR, $filePath); $fileName = array_pop($arrFile); $folder = implode(DIRECTORY_SEPARATOR, $arrFile).DIRECTORY_SEPARATOR; $tmp = new Update(); $tmp->name = $fileName; $tmp->folder = $folder; $tmp->createDate = strftime("%Y-%m-%d %H:%M:%S"); $tmp->save(); echo "Processed: ".$fileName."\n"; unset($tmp); }
[ "protected", "function", "addFileToProcessedList", "(", "string", "$", "filePath", ")", "{", "$", "arrFile", "=", "explode", "(", "DIRECTORY_SEPARATOR", ",", "$", "filePath", ")", ";", "$", "fileName", "=", "array_pop", "(", "$", "arrFile", ")", ";", "$", ...
Puts the Filename into the update table @param string $filePath
[ "Puts", "the", "Filename", "into", "the", "update", "table" ]
68305dac50b1b956f08f41267d0b2912850d8232
https://github.com/leedave/resource-mysql/blob/68305dac50b1b956f08f41267d0b2912850d8232/src/Tools/Update.php#L87-L101
train
leedave/resource-mysql
src/Tools/Update.php
Update.getProcessedFiles
protected function getProcessedFiles() { $sql = "SELECT * FROM `".$this->tableName."` ORDER BY `id` ASC;"; try { $arrResult = $this->getAllRows(); } catch (PDOException $ex) { echo $ex->getMessage().PHP_EOL; return; } foreach ($arrResult as $row) { $this->knownUpdateFiles[$row['id']] = $row['folder'].$row['name']; } }
php
protected function getProcessedFiles() { $sql = "SELECT * FROM `".$this->tableName."` ORDER BY `id` ASC;"; try { $arrResult = $this->getAllRows(); } catch (PDOException $ex) { echo $ex->getMessage().PHP_EOL; return; } foreach ($arrResult as $row) { $this->knownUpdateFiles[$row['id']] = $row['folder'].$row['name']; } }
[ "protected", "function", "getProcessedFiles", "(", ")", "{", "$", "sql", "=", "\"SELECT * FROM `\"", ".", "$", "this", "->", "tableName", ".", "\"` ORDER BY `id` ASC;\"", ";", "try", "{", "$", "arrResult", "=", "$", "this", "->", "getAllRows", "(", ")", ";",...
Get List of processed files, catches exception if db_update does not exist @return void
[ "Get", "List", "of", "processed", "files", "catches", "exception", "if", "db_update", "does", "not", "exist" ]
68305dac50b1b956f08f41267d0b2912850d8232
https://github.com/leedave/resource-mysql/blob/68305dac50b1b956f08f41267d0b2912850d8232/src/Tools/Update.php#L121-L134
train
leedave/resource-mysql
src/Tools/Update.php
Update.findNewFiles
protected function findNewFiles(string $path) : array { $arrReturn = []; $arrFolders = scandir($path); $arrSkip = [ '.', '..', ]; foreach ($arrFolders as $file) { //No Folder Defaults if (in_array($file, $arrSkip)) { continue; } //Process Subfolders if (is_dir($path.$file)) { $arrSubFolderFiles = $this->findNewFiles($path.$file."/"); $arrReturn = $this->addArrayToNewFiles($arrSubFolderFiles, $arrReturn); continue; } $arrReturn[] = $path.$file; } //Remove file from list if already processed foreach($arrReturn as $key => $file) { if (in_array($file, $this->knownUpdateFiles)) { unset($arrReturn[$key]); } } return $arrReturn; }
php
protected function findNewFiles(string $path) : array { $arrReturn = []; $arrFolders = scandir($path); $arrSkip = [ '.', '..', ]; foreach ($arrFolders as $file) { //No Folder Defaults if (in_array($file, $arrSkip)) { continue; } //Process Subfolders if (is_dir($path.$file)) { $arrSubFolderFiles = $this->findNewFiles($path.$file."/"); $arrReturn = $this->addArrayToNewFiles($arrSubFolderFiles, $arrReturn); continue; } $arrReturn[] = $path.$file; } //Remove file from list if already processed foreach($arrReturn as $key => $file) { if (in_array($file, $this->knownUpdateFiles)) { unset($arrReturn[$key]); } } return $arrReturn; }
[ "protected", "function", "findNewFiles", "(", "string", "$", "path", ")", ":", "array", "{", "$", "arrReturn", "=", "[", "]", ";", "$", "arrFolders", "=", "scandir", "(", "$", "path", ")", ";", "$", "arrSkip", "=", "[", "'.'", ",", "'..'", ",", "]"...
Creates an array of Update Files that were not yet processed @param string $path @return array
[ "Creates", "an", "array", "of", "Update", "Files", "that", "were", "not", "yet", "processed" ]
68305dac50b1b956f08f41267d0b2912850d8232
https://github.com/leedave/resource-mysql/blob/68305dac50b1b956f08f41267d0b2912850d8232/src/Tools/Update.php#L141-L171
train
liftkit/document
src/Document/Html.php
Html.addHeader
public function addHeader ($string, $prepend = false) { if ($prepend) { $this->prependHeader($string); } else { $this->headers[] = $string; } }
php
public function addHeader ($string, $prepend = false) { if ($prepend) { $this->prependHeader($string); } else { $this->headers[] = $string; } }
[ "public", "function", "addHeader", "(", "$", "string", ",", "$", "prepend", "=", "false", ")", "{", "if", "(", "$", "prepend", ")", "{", "$", "this", "->", "prependHeader", "(", "$", "string", ")", ";", "}", "else", "{", "$", "this", "->", "headers...
addHeader function. @access public @param string $string @return void
[ "addHeader", "function", "." ]
1f6d409c780e42f1c1d177e70039b039e28e2c53
https://github.com/liftkit/document/blob/1f6d409c780e42f1c1d177e70039b039e28e2c53/src/Document/Html.php#L53-L60
train
liftkit/document
src/Document/Html.php
Html.addMeta
public function addMeta ($name, $content, $attributes = array()) { $html = '<meta name="' . $this->sanitize($name) . '" content="' . $this->sanitize($content) . '"'; foreach ($attributes as $key => $value) { $html .= ' ' . $this->sanitize($key) . '="' . $this->sanitize($value) . '"'; } $html .= ' />'; $this->addHeader($html); }
php
public function addMeta ($name, $content, $attributes = array()) { $html = '<meta name="' . $this->sanitize($name) . '" content="' . $this->sanitize($content) . '"'; foreach ($attributes as $key => $value) { $html .= ' ' . $this->sanitize($key) . '="' . $this->sanitize($value) . '"'; } $html .= ' />'; $this->addHeader($html); }
[ "public", "function", "addMeta", "(", "$", "name", ",", "$", "content", ",", "$", "attributes", "=", "array", "(", ")", ")", "{", "$", "html", "=", "'<meta name=\"'", ".", "$", "this", "->", "sanitize", "(", "$", "name", ")", ".", "'\" content=\"'", ...
addMeta function. Add meta tags to head. @access public @param string $name @param string $content @param array $attributes (default: array()) @return void
[ "addMeta", "function", "." ]
1f6d409c780e42f1c1d177e70039b039e28e2c53
https://github.com/liftkit/document/blob/1f6d409c780e42f1c1d177e70039b039e28e2c53/src/Document/Html.php#L93-L104
train
liftkit/document
src/Document/Html.php
Html.addScript
public function addScript ($src, $prepend = false) { if ($prepend) { array_unshift($this->scriptUrls, $src); } else { $this->scriptUrls[] = $src; } $html = '<script type="text/javascript" src="' . $this->sanitize($src) . '"></script>'; $this->addHeader($html, $prepend); }
php
public function addScript ($src, $prepend = false) { if ($prepend) { array_unshift($this->scriptUrls, $src); } else { $this->scriptUrls[] = $src; } $html = '<script type="text/javascript" src="' . $this->sanitize($src) . '"></script>'; $this->addHeader($html, $prepend); }
[ "public", "function", "addScript", "(", "$", "src", ",", "$", "prepend", "=", "false", ")", "{", "if", "(", "$", "prepend", ")", "{", "array_unshift", "(", "$", "this", "->", "scriptUrls", ",", "$", "src", ")", ";", "}", "else", "{", "$", "this", ...
addScript function. Adds scripts to head. @access public @param string $src @param bool $prepend (default: false) @return void
[ "addScript", "function", "." ]
1f6d409c780e42f1c1d177e70039b039e28e2c53
https://github.com/liftkit/document/blob/1f6d409c780e42f1c1d177e70039b039e28e2c53/src/Document/Html.php#L119-L130
train
liftkit/document
src/Document/Html.php
Html.addStylesheet
public function addStylesheet ($src, $prepend = false) { if ($prepend) { array_unshift($this->stylesheetUrls, $src); } else { $this->stylesheetUrls[] = $src; } $html = '<link rel="stylesheet" type="text/css" href="' . $this->sanitize($src) . '" />'; $this->addHeader($html, $prepend); }
php
public function addStylesheet ($src, $prepend = false) { if ($prepend) { array_unshift($this->stylesheetUrls, $src); } else { $this->stylesheetUrls[] = $src; } $html = '<link rel="stylesheet" type="text/css" href="' . $this->sanitize($src) . '" />'; $this->addHeader($html, $prepend); }
[ "public", "function", "addStylesheet", "(", "$", "src", ",", "$", "prepend", "=", "false", ")", "{", "if", "(", "$", "prepend", ")", "{", "array_unshift", "(", "$", "this", "->", "stylesheetUrls", ",", "$", "src", ")", ";", "}", "else", "{", "$", "...
addStylesheet function. Addes stylesheets to head. @access public @param string $src @param bool $prepend (default: false) @return void
[ "addStylesheet", "function", "." ]
1f6d409c780e42f1c1d177e70039b039e28e2c53
https://github.com/liftkit/document/blob/1f6d409c780e42f1c1d177e70039b039e28e2c53/src/Document/Html.php#L145-L156
train
MESD/JasperReportViewerBundle
Controller/ReportViewerController.php
ReportViewerController.historyAction
public function historyAction($reportUri = null) { //Determine whether to show or hide the report home button $hideHome = $this->container->get('request')->query->get('hideHome') ?: 'false'; //Render and return $response = new Response($this->container->get('templating')->render( 'MesdJasperReportViewerBundle:ReportViewer:reportHistory.html.twig', array( 'reportUri' => $reportUri, 'hideHome' => $hideHome ) ) ); return $response; }
php
public function historyAction($reportUri = null) { //Determine whether to show or hide the report home button $hideHome = $this->container->get('request')->query->get('hideHome') ?: 'false'; //Render and return $response = new Response($this->container->get('templating')->render( 'MesdJasperReportViewerBundle:ReportViewer:reportHistory.html.twig', array( 'reportUri' => $reportUri, 'hideHome' => $hideHome ) ) ); return $response; }
[ "public", "function", "historyAction", "(", "$", "reportUri", "=", "null", ")", "{", "//Determine whether to show or hide the report home button", "$", "hideHome", "=", "$", "this", "->", "container", "->", "get", "(", "'request'", ")", "->", "query", "->", "get",...
Display information and history for a given report @param string $reportUri The url encoded uri of the report to show info for @return Response Rendered page
[ "Display", "information", "and", "history", "for", "a", "given", "report" ]
d51ff079ba79b35c549a7ac472a305d416060d86
https://github.com/MESD/JasperReportViewerBundle/blob/d51ff079ba79b35c549a7ac472a305d416060d86/Controller/ReportViewerController.php#L105-L118
train
MESD/JasperReportViewerBundle
Controller/ReportViewerController.php
ReportViewerController.loadPage
protected function loadPage($requestId, $page) { //Create an array that will be converted into the json response $response = array('success' => true, 'output' => ''); //Load the report $rl = $this->container->get('mesd.jasper.report.loader')->getReportLoader(); try { $report = $rl->getCachedReport($requestId, 'html', array('page' => $page)); } catch(\Exception $e) { $response['success'] = false; $response['output'] = 'An error occured trying to load the report'; $response['totalPages'] = 0; $response['page'] = 0; } if ($response['success']) { $response['success'] = !$report->getError(); $response['output'] = $report->getOutput(); $response['totalPages'] = $report->getTotalPages(); $response['page'] = $report->getPage(); } //return the response array return $response; }
php
protected function loadPage($requestId, $page) { //Create an array that will be converted into the json response $response = array('success' => true, 'output' => ''); //Load the report $rl = $this->container->get('mesd.jasper.report.loader')->getReportLoader(); try { $report = $rl->getCachedReport($requestId, 'html', array('page' => $page)); } catch(\Exception $e) { $response['success'] = false; $response['output'] = 'An error occured trying to load the report'; $response['totalPages'] = 0; $response['page'] = 0; } if ($response['success']) { $response['success'] = !$report->getError(); $response['output'] = $report->getOutput(); $response['totalPages'] = $report->getTotalPages(); $response['page'] = $report->getPage(); } //return the response array return $response; }
[ "protected", "function", "loadPage", "(", "$", "requestId", ",", "$", "page", ")", "{", "//Create an array that will be converted into the json response", "$", "response", "=", "array", "(", "'success'", "=>", "true", ",", "'output'", "=>", "''", ")", ";", "//Load...
Loads a page from the report store @param string $requestId The request id of the cached report @param string $page The page number to display @return array The response array
[ "Loads", "a", "page", "from", "the", "report", "store" ]
d51ff079ba79b35c549a7ac472a305d416060d86
https://github.com/MESD/JasperReportViewerBundle/blob/d51ff079ba79b35c549a7ac472a305d416060d86/Controller/ReportViewerController.php#L151-L175
train
MESD/JasperReportViewerBundle
Controller/ReportViewerController.php
ReportViewerController.executeAction
public function executeAction($reportUri, Request $request) { //Decode the report uri $decodedReportUri = urldecode($reportUri); //Get the form again $form = $this->container->get('mesd.jasper.report.client')->buildReportInputForm( $decodedReportUri, null, array('data' => $request->request->get('form'))); //Process the form $form->handleRequest($request); //If any errors if (!$form->isValid()) { //Get form errors $errors = FormErrorConverter::convertToArray($form); return new JsonResponse(array('success' => false, 'errors' => $errors)); } //Build the report $rb = $this->container->get('mesd.jasper.report.client')->createReportBuilder($decodedReportUri); $rb->setInputParametersArray($form->getData()); $rb->setFormat('html'); $rb->setPage(1); //Run the report and get the request id back $requestId = $rb->runReport(); //Load the first page of the report for the output $response = $this->loadPage($requestId, 1); //Setup the links for the toolbar $response['toolbar'] = $this->container->get('mesd.jasper.reportviewer.linkhelper')->generateToolbarLinks( $requestId, $response['page'], $response['totalPages']); //Return the json response return new JsonResponse($response); }
php
public function executeAction($reportUri, Request $request) { //Decode the report uri $decodedReportUri = urldecode($reportUri); //Get the form again $form = $this->container->get('mesd.jasper.report.client')->buildReportInputForm( $decodedReportUri, null, array('data' => $request->request->get('form'))); //Process the form $form->handleRequest($request); //If any errors if (!$form->isValid()) { //Get form errors $errors = FormErrorConverter::convertToArray($form); return new JsonResponse(array('success' => false, 'errors' => $errors)); } //Build the report $rb = $this->container->get('mesd.jasper.report.client')->createReportBuilder($decodedReportUri); $rb->setInputParametersArray($form->getData()); $rb->setFormat('html'); $rb->setPage(1); //Run the report and get the request id back $requestId = $rb->runReport(); //Load the first page of the report for the output $response = $this->loadPage($requestId, 1); //Setup the links for the toolbar $response['toolbar'] = $this->container->get('mesd.jasper.reportviewer.linkhelper')->generateToolbarLinks( $requestId, $response['page'], $response['totalPages']); //Return the json response return new JsonResponse($response); }
[ "public", "function", "executeAction", "(", "$", "reportUri", ",", "Request", "$", "request", ")", "{", "//Decode the report uri", "$", "decodedReportUri", "=", "urldecode", "(", "$", "reportUri", ")", ";", "//Get the form again", "$", "form", "=", "$", "this", ...
Runs a report @param string $reportUri The jasper server uri for the report @param Request $request The request from the submitted request input form @return JsonResponse Json Response giving links to the output or what errors occured
[ "Runs", "a", "report" ]
d51ff079ba79b35c549a7ac472a305d416060d86
https://github.com/MESD/JasperReportViewerBundle/blob/d51ff079ba79b35c549a7ac472a305d416060d86/Controller/ReportViewerController.php#L186-L221
train
MESD/JasperReportViewerBundle
Controller/ReportViewerController.php
ReportViewerController.listJsonAction
public function listJsonAction() { //Get the folder $folderUri = $this->container->get('request')->query->get('id'); //Set folder uri to null to use the default if the root is requested ('#') if ('#' === $folderUri) { $folder = null; } else { $folder = $folderUri; } //Get the resource descriptors (not recursively) $resources = $this->container->get('mesd.jasper.report.client')->getResourceList($folder, false); //Convert the resources into an array to encode in json in the way jstree can read them $response = array(); foreach($resources as $resource) { $data = array(); $data['id'] = $resource->getUriString(); $data['parent'] = $folderUri; $data['icon'] = false; if ('reportUnit' === $resource->getWsType()) { //Report object specific settings $data['text'] = '<i id="' . $data['id'] . '-icon" class="icon-file"></i> ' . $resource->getLabel(); $data['children'] = false; //Set the href to the report input form $data['a_attr'] = array('href' => $this->container->get('router')->generate('MesdJasperReportViewerBundle_display_report_viewer', array('reportUri' => rawurlencode($resource->getUriString())))); $data['dump'] = $resource->getUriString(); } elseif ('folder' === $resource->getWsType()) { //Folder object specific settings $data['text'] = '<i id="' . $data['id'] . '-icon" class="icon-folder-close"></i> ' . $resource->getLabel(); $data['children'] = true; } $response[] = $data; } //Get the resources return new JsonResponse($response); }
php
public function listJsonAction() { //Get the folder $folderUri = $this->container->get('request')->query->get('id'); //Set folder uri to null to use the default if the root is requested ('#') if ('#' === $folderUri) { $folder = null; } else { $folder = $folderUri; } //Get the resource descriptors (not recursively) $resources = $this->container->get('mesd.jasper.report.client')->getResourceList($folder, false); //Convert the resources into an array to encode in json in the way jstree can read them $response = array(); foreach($resources as $resource) { $data = array(); $data['id'] = $resource->getUriString(); $data['parent'] = $folderUri; $data['icon'] = false; if ('reportUnit' === $resource->getWsType()) { //Report object specific settings $data['text'] = '<i id="' . $data['id'] . '-icon" class="icon-file"></i> ' . $resource->getLabel(); $data['children'] = false; //Set the href to the report input form $data['a_attr'] = array('href' => $this->container->get('router')->generate('MesdJasperReportViewerBundle_display_report_viewer', array('reportUri' => rawurlencode($resource->getUriString())))); $data['dump'] = $resource->getUriString(); } elseif ('folder' === $resource->getWsType()) { //Folder object specific settings $data['text'] = '<i id="' . $data['id'] . '-icon" class="icon-folder-close"></i> ' . $resource->getLabel(); $data['children'] = true; } $response[] = $data; } //Get the resources return new JsonResponse($response); }
[ "public", "function", "listJsonAction", "(", ")", "{", "//Get the folder", "$", "folderUri", "=", "$", "this", "->", "container", "->", "get", "(", "'request'", ")", "->", "query", "->", "get", "(", "'id'", ")", ";", "//Set folder uri to null to use the default ...
Gets the resources contained in the requested folder Folder name comes in via a query string parameter ('#' to use the default) @return JsonResponse The Json Object of the returned resources
[ "Gets", "the", "resources", "contained", "in", "the", "requested", "folder" ]
d51ff079ba79b35c549a7ac472a305d416060d86
https://github.com/MESD/JasperReportViewerBundle/blob/d51ff079ba79b35c549a7ac472a305d416060d86/Controller/ReportViewerController.php#L231-L271
train
MESD/JasperReportViewerBundle
Controller/ReportViewerController.php
ReportViewerController.reportHistoryJsonAction
public function reportHistoryJsonAction($reportUri = null) { //Get the sent parameters from datatables $limit = $this->container->get('request')->query->get('length'); $offset = $this->container->get('request')->query->get('start'); //Create a new repsonse array that will be converted to json $response = array(); //Get the history for the given report from the report history $records = $this->container->get('mesd.jasper.report.history')->getReportHistoryDisplay( urldecode($reportUri), true, array('limit' => $limit, 'offset' => $offset)); if ($reportUri) { //Get the count of records $count = $this->container->get('mesd.jasper.report.history')->loadHistoryForReport( urldecode($reportUri), true, array('count' => true)); } else { //Get the count of records $count = $this->container->get('mesd.jasper.report.history')->loadRecentHistory( true, array('count' => true)); } $response['recordsTotal'] = $count; $response['recordsFiltered'] = $count; //Convert the records to an array $response['data'] = array(); foreach($records as $record) { //Create the links $links = array(); foreach(json_decode($record['formats']) as $format) { //If html handle it differently, else export like usual if ('html' === $format) { $href = $this->container->get('router')->generate('MesdJasperReportViewerBundle_display_history_report_viewer', array( 'reportUri' => urlencode($record['report']), 'existing' => $record['requestId'] ) ); } else { $href = $this->container->get('router')->generate('MesdJasperReportBundle_export_cached_report', array( 'requestId' => $record['requestId'], 'format' => $format ) ); } $links[] = '<a href="' . $href . '">' . $format . '</a>'; } //Convert to the format that datatables can read $response['data'][] = array( $record['report'], $record['date']->format('Y-m-d H:i:s'), $record['parameters'], implode(' ', $links) ); } //Send back the Json return new JsonResponse($response); }
php
public function reportHistoryJsonAction($reportUri = null) { //Get the sent parameters from datatables $limit = $this->container->get('request')->query->get('length'); $offset = $this->container->get('request')->query->get('start'); //Create a new repsonse array that will be converted to json $response = array(); //Get the history for the given report from the report history $records = $this->container->get('mesd.jasper.report.history')->getReportHistoryDisplay( urldecode($reportUri), true, array('limit' => $limit, 'offset' => $offset)); if ($reportUri) { //Get the count of records $count = $this->container->get('mesd.jasper.report.history')->loadHistoryForReport( urldecode($reportUri), true, array('count' => true)); } else { //Get the count of records $count = $this->container->get('mesd.jasper.report.history')->loadRecentHistory( true, array('count' => true)); } $response['recordsTotal'] = $count; $response['recordsFiltered'] = $count; //Convert the records to an array $response['data'] = array(); foreach($records as $record) { //Create the links $links = array(); foreach(json_decode($record['formats']) as $format) { //If html handle it differently, else export like usual if ('html' === $format) { $href = $this->container->get('router')->generate('MesdJasperReportViewerBundle_display_history_report_viewer', array( 'reportUri' => urlencode($record['report']), 'existing' => $record['requestId'] ) ); } else { $href = $this->container->get('router')->generate('MesdJasperReportBundle_export_cached_report', array( 'requestId' => $record['requestId'], 'format' => $format ) ); } $links[] = '<a href="' . $href . '">' . $format . '</a>'; } //Convert to the format that datatables can read $response['data'][] = array( $record['report'], $record['date']->format('Y-m-d H:i:s'), $record['parameters'], implode(' ', $links) ); } //Send back the Json return new JsonResponse($response); }
[ "public", "function", "reportHistoryJsonAction", "(", "$", "reportUri", "=", "null", ")", "{", "//Get the sent parameters from datatables", "$", "limit", "=", "$", "this", "->", "container", "->", "get", "(", "'request'", ")", "->", "query", "->", "get", "(", ...
Returns the json of a @param string $reportUri Url encoded report uri @return Response The json representation of this reports history table
[ "Returns", "the", "json", "of", "a" ]
d51ff079ba79b35c549a7ac472a305d416060d86
https://github.com/MESD/JasperReportViewerBundle/blob/d51ff079ba79b35c549a7ac472a305d416060d86/Controller/ReportViewerController.php#L281-L340
train
FiveLab/ResourceBundle
src/EventListener/ValidateResourceListener.php
ValidateResourceListener.onKernelControllerArguments
public function onKernelControllerArguments(FilterControllerArgumentsEvent $event): void { $arguments = $event->getArguments(); foreach ($arguments as $argument) { if ($argument instanceof ResourceInterface) { $violationList = $this->validator->validate($argument); if (count($violationList)) { throw ViolationListException::create($violationList); } } } }
php
public function onKernelControllerArguments(FilterControllerArgumentsEvent $event): void { $arguments = $event->getArguments(); foreach ($arguments as $argument) { if ($argument instanceof ResourceInterface) { $violationList = $this->validator->validate($argument); if (count($violationList)) { throw ViolationListException::create($violationList); } } } }
[ "public", "function", "onKernelControllerArguments", "(", "FilterControllerArgumentsEvent", "$", "event", ")", ":", "void", "{", "$", "arguments", "=", "$", "event", "->", "getArguments", "(", ")", ";", "foreach", "(", "$", "arguments", "as", "$", "argument", ...
Listen kernel.controller_arguments event for validate input resources @param FilterControllerArgumentsEvent $event @throws ViolationListException
[ "Listen", "kernel", ".", "controller_arguments", "event", "for", "validate", "input", "resources" ]
048fce7be5357dc23fef1402ef8ca213489e8154
https://github.com/FiveLab/ResourceBundle/blob/048fce7be5357dc23fef1402ef8ca213489e8154/src/EventListener/ValidateResourceListener.php#L50-L63
train
metashock/Jm_Autoloader
lib/php/Jm/Autoloader.php
Jm_Autoloader.addPath
public function addPath($path, $namespace = '', $prepend = FALSE) { if ($prepend === TRUE) { return $this->prependPath($path, $namespace); } else { if (!empty($namespace)) { $path = array ( $path, str_replace('_', '/', $namespace) ); } $this->paths []= $path; } return $this; }
php
public function addPath($path, $namespace = '', $prepend = FALSE) { if ($prepend === TRUE) { return $this->prependPath($path, $namespace); } else { if (!empty($namespace)) { $path = array ( $path, str_replace('_', '/', $namespace) ); } $this->paths []= $path; } return $this; }
[ "public", "function", "addPath", "(", "$", "path", ",", "$", "namespace", "=", "''", ",", "$", "prepend", "=", "FALSE", ")", "{", "if", "(", "$", "prepend", "===", "TRUE", ")", "{", "return", "$", "this", "->", "prependPath", "(", "$", "path", ",",...
Adds a path to the search path array @param string $path A classpath @param string $namespace The root namespace of $path. If not empty or omitted Jm_Autoloader expects that classes in the path are named like $namespace_Class_Name @param boolean $prepend If set to true the path will be prepended instead of being appended. defaults to false @return Jm_Autoloader
[ "Adds", "a", "path", "to", "the", "search", "path", "array" ]
0173dcef12a7f988985518685407ed33ede149a9
https://github.com/metashock/Jm_Autoloader/blob/0173dcef12a7f988985518685407ed33ede149a9/lib/php/Jm/Autoloader.php#L126-L138
train
bishopb/vanilla
library/core/class.router.php
Gdn_Router.SetRoute
public function SetRoute($Route, $Destination, $Type, $Save = TRUE) { $Key = $this->_EncodeRouteKey($Route); SaveToConfig('Routes.'.$Key, array($Destination, $Type), $Save); $this->_LoadRoutes(); }
php
public function SetRoute($Route, $Destination, $Type, $Save = TRUE) { $Key = $this->_EncodeRouteKey($Route); SaveToConfig('Routes.'.$Key, array($Destination, $Type), $Save); $this->_LoadRoutes(); }
[ "public", "function", "SetRoute", "(", "$", "Route", ",", "$", "Destination", ",", "$", "Type", ",", "$", "Save", "=", "TRUE", ")", "{", "$", "Key", "=", "$", "this", "->", "_EncodeRouteKey", "(", "$", "Route", ")", ";", "SaveToConfig", "(", "'Routes...
Update or add a route to the config table @param string $Route @param string $Destination @param string $Type @param bool $Save Optional. Save this to the config or just in memory?
[ "Update", "or", "add", "a", "route", "to", "the", "config", "table" ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.router.php#L75-L79
train
wasabi-cms/cms
src/Model/Table/PagesTable.php
PagesTable.getForFrontend
public function getForFrontend($pageId) { return $this->find() ->contain(['Current', 'Attributes']) ->formatResults([$this, 'formatAttributes']) ->where([$this->aliasField('id') => $pageId]) ->first(); }
php
public function getForFrontend($pageId) { return $this->find() ->contain(['Current', 'Attributes']) ->formatResults([$this, 'formatAttributes']) ->where([$this->aliasField('id') => $pageId]) ->first(); }
[ "public", "function", "getForFrontend", "(", "$", "pageId", ")", "{", "return", "$", "this", "->", "find", "(", ")", "->", "contain", "(", "[", "'Current'", ",", "'Attributes'", "]", ")", "->", "formatResults", "(", "[", "$", "this", ",", "'formatAttribu...
Find a single page including content and attributes for output in the frontend. @param int $pageId The page id. @return Page|null
[ "Find", "a", "single", "page", "including", "content", "and", "attributes", "for", "output", "in", "the", "frontend", "." ]
2787b6422ea1d719cf49951b3253fd0ac31d22ca
https://github.com/wasabi-cms/cms/blob/2787b6422ea1d719cf49951b3253fd0ac31d22ca/src/Model/Table/PagesTable.php#L181-L188
train
znframework/package-security
Injection.php
Injection.encode
public static function encode(String $string) : String { $secBadChars = Properties::$injectionBadChars; if( ! empty($secBadChars) ) { foreach( $secBadChars as $badChar => $changeChar ) { if( is_numeric($badChar) ) { $badChar = $changeChar; $changeChar = ''; } $badChar = trim($badChar, '/'); $string = preg_replace('/'.$badChar.'/xi', $changeChar, $string); } } return addslashes(trim($string)); }
php
public static function encode(String $string) : String { $secBadChars = Properties::$injectionBadChars; if( ! empty($secBadChars) ) { foreach( $secBadChars as $badChar => $changeChar ) { if( is_numeric($badChar) ) { $badChar = $changeChar; $changeChar = ''; } $badChar = trim($badChar, '/'); $string = preg_replace('/'.$badChar.'/xi', $changeChar, $string); } } return addslashes(trim($string)); }
[ "public", "static", "function", "encode", "(", "String", "$", "string", ")", ":", "String", "{", "$", "secBadChars", "=", "Properties", "::", "$", "injectionBadChars", ";", "if", "(", "!", "empty", "(", "$", "secBadChars", ")", ")", "{", "foreach", "(", ...
Encode Injection Chars @param string $string @return string
[ "Encode", "Injection", "Chars" ]
dfced60e243ab9f52a1b5bbdb695bfc39b26cac0
https://github.com/znframework/package-security/blob/dfced60e243ab9f52a1b5bbdb695bfc39b26cac0/Injection.php#L32-L52
train
znframework/package-security
Injection.php
Injection.nailEncode
public static function nailEncode(String $str) : String { $str = str_replace(array_keys(self::$nailChars), array_values(self::$nailChars), $str); return $str; }
php
public static function nailEncode(String $str) : String { $str = str_replace(array_keys(self::$nailChars), array_values(self::$nailChars), $str); return $str; }
[ "public", "static", "function", "nailEncode", "(", "String", "$", "str", ")", ":", "String", "{", "$", "str", "=", "str_replace", "(", "array_keys", "(", "self", "::", "$", "nailChars", ")", ",", "array_values", "(", "self", "::", "$", "nailChars", ")", ...
Encode Nail Chars @param string $string @return string
[ "Encode", "Nail", "Chars" ]
dfced60e243ab9f52a1b5bbdb695bfc39b26cac0
https://github.com/znframework/package-security/blob/dfced60e243ab9f52a1b5bbdb695bfc39b26cac0/Injection.php#L73-L78
train
znframework/package-security
Injection.php
Injection.nailDecode
public static function nailDecode(String $str) : String { $str = str_replace(array_values(self::$nailChars), array_keys(self::$nailChars), $str); return $str; }
php
public static function nailDecode(String $str) : String { $str = str_replace(array_values(self::$nailChars), array_keys(self::$nailChars), $str); return $str; }
[ "public", "static", "function", "nailDecode", "(", "String", "$", "str", ")", ":", "String", "{", "$", "str", "=", "str_replace", "(", "array_values", "(", "self", "::", "$", "nailChars", ")", ",", "array_keys", "(", "self", "::", "$", "nailChars", ")", ...
Decode Nail Chars @param string $string @return string
[ "Decode", "Nail", "Chars" ]
dfced60e243ab9f52a1b5bbdb695bfc39b26cac0
https://github.com/znframework/package-security/blob/dfced60e243ab9f52a1b5bbdb695bfc39b26cac0/Injection.php#L87-L92
train
webriq/core
module/Menu/src/Grid/Menu/Model/Menu/Mapper.php
Mapper.parseProxyData
protected function parseProxyData( & $data ) { if ( empty( $data ) ) { return array(); } $result = array(); foreach ( json_decode( $data, true ) as $field ) { if ( empty( $field['name'] ) ) { continue; } $name = (string) $field['name']; $parts = explode( '.', $name, 2 ); $value = isset( $field['value'] ) ? $field['value'] : null; if ( count( $parts ) > 1 ) { list( $name, $sub ) = $parts; if ( isset( $result[$name] ) ) { if ( ! is_array( $result[$name] ) ) { $result[$name] = (array) $result[$name]; } } else { $result[$name] = array(); } $result[$name][$sub] = $value; } else { $result[$name] = $value; } } foreach ( $result as & $value ) { if ( is_array( $value ) ) { uksort( $value, 'strnatcmp' ); } } return $result; }
php
protected function parseProxyData( & $data ) { if ( empty( $data ) ) { return array(); } $result = array(); foreach ( json_decode( $data, true ) as $field ) { if ( empty( $field['name'] ) ) { continue; } $name = (string) $field['name']; $parts = explode( '.', $name, 2 ); $value = isset( $field['value'] ) ? $field['value'] : null; if ( count( $parts ) > 1 ) { list( $name, $sub ) = $parts; if ( isset( $result[$name] ) ) { if ( ! is_array( $result[$name] ) ) { $result[$name] = (array) $result[$name]; } } else { $result[$name] = array(); } $result[$name][$sub] = $value; } else { $result[$name] = $value; } } foreach ( $result as & $value ) { if ( is_array( $value ) ) { uksort( $value, 'strnatcmp' ); } } return $result; }
[ "protected", "function", "parseProxyData", "(", "&", "$", "data", ")", "{", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "json_decode", "(", ...
Parse proxy-data Like: <pre> &lt;struct&gt; [{"name":"{key}","value":"{value}"}] &nbsp;... &lt;/struct&gt; </pre> @param string $data @return array
[ "Parse", "proxy", "-", "data" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Menu/src/Grid/Menu/Model/Menu/Mapper.php#L367-L419
train
webriq/core
module/Menu/src/Grid/Menu/Model/Menu/Mapper.php
Mapper.findRenderList
public function findRenderList( $id = null ) { $platform = $this->getDbAdapter() ->getPlatform(); $columns = $this->getSelectColumns(); $columns['_depth'] = new Sql\Expression( '(' . $this->sql( null ) ->select( array( 'parent' => static::$tableName ) ) ->columns( array( new Sql\Expression( 'COUNT(*)' ) ) ) ->where( array( new Sql\Predicate\Expression( $platform->quoteIdentifierChain( array( static::$tableName, 'left' ) ) . ' BETWEEN ' . $platform->quoteIdentifierChain( array( 'parent', 'left' ) ) . ' AND ' . $platform->quoteIdentifierChain( array( 'parent', 'right' ) ) ), ) ) ->getSqlString( $platform ) . ')' ); $select = $this->select( $columns ) ->order( 'left' ); if ( null !== $id ) { $select->join( array( 'parent' => self::$tableName ), '( ' . self::$tableName . '.left BETWEEN parent.left AND parent.right ) ', array() ) ->where( array( 'parent.id' => $id ) ); } /* @var $result \Zend\Db\Adapter\Driver\ResultInterface */ $return = array(); $result = $this->sql() ->prepareStatementForSqlObject( $select ) ->execute(); foreach ( $result as $row ) { $depth = (int) $row['_depth']; unset( $row['_depth'] ); $return[] = array( $depth, $this->selected( $row ) ); } return $return; }
php
public function findRenderList( $id = null ) { $platform = $this->getDbAdapter() ->getPlatform(); $columns = $this->getSelectColumns(); $columns['_depth'] = new Sql\Expression( '(' . $this->sql( null ) ->select( array( 'parent' => static::$tableName ) ) ->columns( array( new Sql\Expression( 'COUNT(*)' ) ) ) ->where( array( new Sql\Predicate\Expression( $platform->quoteIdentifierChain( array( static::$tableName, 'left' ) ) . ' BETWEEN ' . $platform->quoteIdentifierChain( array( 'parent', 'left' ) ) . ' AND ' . $platform->quoteIdentifierChain( array( 'parent', 'right' ) ) ), ) ) ->getSqlString( $platform ) . ')' ); $select = $this->select( $columns ) ->order( 'left' ); if ( null !== $id ) { $select->join( array( 'parent' => self::$tableName ), '( ' . self::$tableName . '.left BETWEEN parent.left AND parent.right ) ', array() ) ->where( array( 'parent.id' => $id ) ); } /* @var $result \Zend\Db\Adapter\Driver\ResultInterface */ $return = array(); $result = $this->sql() ->prepareStatementForSqlObject( $select ) ->execute(); foreach ( $result as $row ) { $depth = (int) $row['_depth']; unset( $row['_depth'] ); $return[] = array( $depth, $this->selected( $row ) ); } return $return; }
[ "public", "function", "findRenderList", "(", "$", "id", "=", "null", ")", "{", "$", "platform", "=", "$", "this", "->", "getDbAdapter", "(", ")", "->", "getPlatform", "(", ")", ";", "$", "columns", "=", "$", "this", "->", "getSelectColumns", "(", ")", ...
Find render-list @param int|null $id @return \Menu\Model\Menu\StructureInterface[]
[ "Find", "render", "-", "list" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Menu/src/Grid/Menu/Model/Menu/Mapper.php#L455-L503
train
webriq/core
module/Menu/src/Grid/Menu/Model/Menu/Mapper.php
Mapper.saveSingleProperty
private function saveSingleProperty( $id, $name, $value ) { $sql = $this->sql( $this->getTableInSchema( static::$propertyTableName ) ); $update = $sql->update() ->set( array( 'value' => $value, ) ) ->where( array( 'menuId' => $id, 'name' => $name, ) ); $affected = $sql->prepareStatementForSqlObject( $update ) ->execute() ->getAffectedRows(); if ( $affected < 1 ) { $insert = $sql->insert() ->values( array( 'menuId' => $id, 'name' => $name, 'value' => $value, ) ); $affected = $sql->prepareStatementForSqlObject( $insert ) ->execute() ->getAffectedRows(); } return $affected; }
php
private function saveSingleProperty( $id, $name, $value ) { $sql = $this->sql( $this->getTableInSchema( static::$propertyTableName ) ); $update = $sql->update() ->set( array( 'value' => $value, ) ) ->where( array( 'menuId' => $id, 'name' => $name, ) ); $affected = $sql->prepareStatementForSqlObject( $update ) ->execute() ->getAffectedRows(); if ( $affected < 1 ) { $insert = $sql->insert() ->values( array( 'menuId' => $id, 'name' => $name, 'value' => $value, ) ); $affected = $sql->prepareStatementForSqlObject( $insert ) ->execute() ->getAffectedRows(); } return $affected; }
[ "private", "function", "saveSingleProperty", "(", "$", "id", ",", "$", "name", ",", "$", "value", ")", "{", "$", "sql", "=", "$", "this", "->", "sql", "(", "$", "this", "->", "getTableInSchema", "(", "static", "::", "$", "propertyTableName", ")", ")", ...
Save a single property @param int $id @param string $name @param mixed $value @return int
[ "Save", "a", "single", "property" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Menu/src/Grid/Menu/Model/Menu/Mapper.php#L513-L547
train
webriq/core
module/Menu/src/Grid/Menu/Model/Menu/Mapper.php
Mapper.saveProperty
protected function saveProperty( $id, $name, $value ) { $rows = 0; $sql = $this->sql( $this->getTableInSchema( static::$propertyTableName ) ); $like = strtr( $name, array( '\\' => '\\\\', '%' => '\%', '_' => '\_', ) ) . '.%'; if ( is_array( $value ) ) { $nameLikeOrEq = new Sql\Predicate\PredicateSet( array( new Sql\Predicate\Like( 'name', $like ), new Sql\Predicate\Operator( 'name', Sql\Predicate\Operator::OP_EQ, $name ) ), Sql\Predicate\PredicateSet::OP_OR ); if ( empty( $value ) ) { $delete = $sql->delete() ->where( array( 'menuId' => $id, $nameLikeOrEq, ) ); $rows += $sql->prepareStatementForSqlObject( $delete ) ->execute() ->getAffectedRows(); } else { $keys = array(); foreach ( $value as $idx => $val ) { $keys[] = $key = $name . '.' . $idx; $rows += $this->saveSingleProperty( $id, $key, $val ); } $delete = $sql->delete() ->where( array( 'menuId' => $id, $nameLikeOrEq, new NotIn( 'name', $keys ), ) ); $rows += $sql->prepareStatementForSqlObject( $delete ) ->execute() ->getAffectedRows(); } } else { $rows += $this->saveSingleProperty( $id, $name, $value ); $delete = $sql->delete() ->where( array( 'menuId' => $id, new Sql\Predicate\Like( 'name', $like ), ) ); $rows += $sql->prepareStatementForSqlObject( $delete ) ->execute() ->getAffectedRows(); } return $rows; }
php
protected function saveProperty( $id, $name, $value ) { $rows = 0; $sql = $this->sql( $this->getTableInSchema( static::$propertyTableName ) ); $like = strtr( $name, array( '\\' => '\\\\', '%' => '\%', '_' => '\_', ) ) . '.%'; if ( is_array( $value ) ) { $nameLikeOrEq = new Sql\Predicate\PredicateSet( array( new Sql\Predicate\Like( 'name', $like ), new Sql\Predicate\Operator( 'name', Sql\Predicate\Operator::OP_EQ, $name ) ), Sql\Predicate\PredicateSet::OP_OR ); if ( empty( $value ) ) { $delete = $sql->delete() ->where( array( 'menuId' => $id, $nameLikeOrEq, ) ); $rows += $sql->prepareStatementForSqlObject( $delete ) ->execute() ->getAffectedRows(); } else { $keys = array(); foreach ( $value as $idx => $val ) { $keys[] = $key = $name . '.' . $idx; $rows += $this->saveSingleProperty( $id, $key, $val ); } $delete = $sql->delete() ->where( array( 'menuId' => $id, $nameLikeOrEq, new NotIn( 'name', $keys ), ) ); $rows += $sql->prepareStatementForSqlObject( $delete ) ->execute() ->getAffectedRows(); } } else { $rows += $this->saveSingleProperty( $id, $name, $value ); $delete = $sql->delete() ->where( array( 'menuId' => $id, new Sql\Predicate\Like( 'name', $like ), ) ); $rows += $sql->prepareStatementForSqlObject( $delete ) ->execute() ->getAffectedRows(); } return $rows; }
[ "protected", "function", "saveProperty", "(", "$", "id", ",", "$", "name", ",", "$", "value", ")", "{", "$", "rows", "=", "0", ";", "$", "sql", "=", "$", "this", "->", "sql", "(", "$", "this", "->", "getTableInSchema", "(", "static", "::", "$", "...
Save a property @param int $id @param string $name @param mixed $value @return int
[ "Save", "a", "property" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Menu/src/Grid/Menu/Model/Menu/Mapper.php#L557-L627
train
webriq/core
module/Menu/src/Grid/Menu/Model/Menu/Mapper.php
Mapper.saveLabel
protected function saveLabel( $id, $label ) { $locale = $this->getLocale(); $sql = $this->sql( $this->getTableInSchema( static::$labelTableName ) ); $update = $sql->update() ->set( array( 'label' => $label, ) ) ->where( array( 'menuId' => $id, 'locale' => $locale, ) ); $affected = $sql->prepareStatementForSqlObject( $update ) ->execute() ->getAffectedRows(); if ( $affected < 1 ) { $insert = $sql->insert() ->values( array( 'menuId' => $id, 'locale' => $locale, 'label' => $label, ) ); $affected = $sql->prepareStatementForSqlObject( $insert ) ->execute() ->getAffectedRows(); } return $affected; }
php
protected function saveLabel( $id, $label ) { $locale = $this->getLocale(); $sql = $this->sql( $this->getTableInSchema( static::$labelTableName ) ); $update = $sql->update() ->set( array( 'label' => $label, ) ) ->where( array( 'menuId' => $id, 'locale' => $locale, ) ); $affected = $sql->prepareStatementForSqlObject( $update ) ->execute() ->getAffectedRows(); if ( $affected < 1 ) { $insert = $sql->insert() ->values( array( 'menuId' => $id, 'locale' => $locale, 'label' => $label, ) ); $affected = $sql->prepareStatementForSqlObject( $insert ) ->execute() ->getAffectedRows(); } return $affected; }
[ "protected", "function", "saveLabel", "(", "$", "id", ",", "$", "label", ")", "{", "$", "locale", "=", "$", "this", "->", "getLocale", "(", ")", ";", "$", "sql", "=", "$", "this", "->", "sql", "(", "$", "this", "->", "getTableInSchema", "(", "stati...
Save a label @param int $id @param string $label @return int
[ "Save", "a", "label" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Menu/src/Grid/Menu/Model/Menu/Mapper.php#L636-L671
train
webriq/core
module/Menu/src/Grid/Menu/Model/Menu/Mapper.php
Mapper.interleaveParagraphs
public function interleaveParagraphs( $updateNode, $likeNode ) { return $this->sql() ->menu_interleave_paragraph( (int) $updateNode, (int) $likeNode ); }
php
public function interleaveParagraphs( $updateNode, $likeNode ) { return $this->sql() ->menu_interleave_paragraph( (int) $updateNode, (int) $likeNode ); }
[ "public", "function", "interleaveParagraphs", "(", "$", "updateNode", ",", "$", "likeNode", ")", "{", "return", "$", "this", "->", "sql", "(", ")", "->", "menu_interleave_paragraph", "(", "(", "int", ")", "$", "updateNode", ",", "(", "int", ")", "$", "li...
Interleave paragraph-nodes Update $updateNode's descendant menu-paragraphs to be more like in $likeNode's. @param int $updateNode @param int $likeNode @return bool
[ "Interleave", "paragraph", "-", "nodes" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Menu/src/Grid/Menu/Model/Menu/Mapper.php#L739-L744
train
mchorse/crystal-edge.php
src/FileSystemExport.php
FileSystemExport.export
public function export(Logger $logger = null) { foreach ($this->site->process() as $path => $content) { $dest = "{$this->path}/$path"; $folder = substr($dest, 0, strrpos($dest, '/')); if (!is_dir($folder)) { mkdir($folder, 0777, true); } if (file_put_contents($dest, $content['output']) && $logger) { $logger->log(Logger::INFO, 'Web page %s was compiled at %s', [$path, $dest]); } } return true; }
php
public function export(Logger $logger = null) { foreach ($this->site->process() as $path => $content) { $dest = "{$this->path}/$path"; $folder = substr($dest, 0, strrpos($dest, '/')); if (!is_dir($folder)) { mkdir($folder, 0777, true); } if (file_put_contents($dest, $content['output']) && $logger) { $logger->log(Logger::INFO, 'Web page %s was compiled at %s', [$path, $dest]); } } return true; }
[ "public", "function", "export", "(", "Logger", "$", "logger", "=", "null", ")", "{", "foreach", "(", "$", "this", "->", "site", "->", "process", "(", ")", "as", "$", "path", "=>", "$", "content", ")", "{", "$", "dest", "=", "\"{$this->path}/$path\"", ...
Export a site to build folder
[ "Export", "a", "site", "to", "build", "folder" ]
b030f3a124be9ac0b76ed180ca31035180ab9321
https://github.com/mchorse/crystal-edge.php/blob/b030f3a124be9ac0b76ed180ca31035180ab9321/src/FileSystemExport.php#L35-L54
train
SergioMadness/framework
framework/components/i18n/Fabric.php
Fabric.getTranslator
public function getTranslator($type, array $params = []) { $result = null; if (!isset($params['language'])) { throw new \Exception('Need \'language\' param'); } switch ($type) { case interfaces\Translator::TRANSLATOR_FILE: $result = new FileTranslator(); if (!isset($params['dir'])) { throw new \Exception('Need \'dir\' param'); } $result->setDir($params['dir']); $result->setLanguage($params['language']); break; case interfaces\Translator::TRANSLATOR_ARRAY: $result = new ArrayTranslator(); if (!isset($params['map'])) { throw new \Exception('Need \'map\' param'); } $result->setMap($params['map']); $result->setLanguage($params['language']); break; case interfaces\Translator::TRANSLATOR_DB: $result = new DBTranslator(); if (!isset($params['aliasFieldName'])) { throw new \Exception('Need \'aliasFieldName\' param'); } if (!isset($params['languageFieldName'])) { throw new \Exception('Need \'languageFieldName\' param'); } if (!isset($params['resultFieldName'])) { throw new \Exception('Need \'resultFieldName\' param'); } if (!isset($params['table'])) { throw new \Exception('Need \'table\' param'); } if (!isset($params['connection'])) { throw new \Exception('Need \'connection\' param'); } $result->setAliasFieldName($params['aliasFieldName']); $result->setResultFieldName($params['resultFieldName']); $result->setTableName($params['table']); $result->setLanguageFieldName($params['languageFieldName']); $result->setQueryBuilder(\pwf\basic\db\QueryBuilder::select() ->setConditionBuilder(\pwf\basic\db\QueryBuilder::getConditionBuilder())); $result->setConnection(is_string($params['connection']) ? \pwf\basic\Application::$instance->getComponent($params['connection']) : $params['connection']); $result->setLanguage($params['language']); break; } return $result; }
php
public function getTranslator($type, array $params = []) { $result = null; if (!isset($params['language'])) { throw new \Exception('Need \'language\' param'); } switch ($type) { case interfaces\Translator::TRANSLATOR_FILE: $result = new FileTranslator(); if (!isset($params['dir'])) { throw new \Exception('Need \'dir\' param'); } $result->setDir($params['dir']); $result->setLanguage($params['language']); break; case interfaces\Translator::TRANSLATOR_ARRAY: $result = new ArrayTranslator(); if (!isset($params['map'])) { throw new \Exception('Need \'map\' param'); } $result->setMap($params['map']); $result->setLanguage($params['language']); break; case interfaces\Translator::TRANSLATOR_DB: $result = new DBTranslator(); if (!isset($params['aliasFieldName'])) { throw new \Exception('Need \'aliasFieldName\' param'); } if (!isset($params['languageFieldName'])) { throw new \Exception('Need \'languageFieldName\' param'); } if (!isset($params['resultFieldName'])) { throw new \Exception('Need \'resultFieldName\' param'); } if (!isset($params['table'])) { throw new \Exception('Need \'table\' param'); } if (!isset($params['connection'])) { throw new \Exception('Need \'connection\' param'); } $result->setAliasFieldName($params['aliasFieldName']); $result->setResultFieldName($params['resultFieldName']); $result->setTableName($params['table']); $result->setLanguageFieldName($params['languageFieldName']); $result->setQueryBuilder(\pwf\basic\db\QueryBuilder::select() ->setConditionBuilder(\pwf\basic\db\QueryBuilder::getConditionBuilder())); $result->setConnection(is_string($params['connection']) ? \pwf\basic\Application::$instance->getComponent($params['connection']) : $params['connection']); $result->setLanguage($params['language']); break; } return $result; }
[ "public", "function", "getTranslator", "(", "$", "type", ",", "array", "$", "params", "=", "[", "]", ")", "{", "$", "result", "=", "null", ";", "if", "(", "!", "isset", "(", "$", "params", "[", "'language'", "]", ")", ")", "{", "throw", "new", "\...
Get translator by type @param string $type @param array $params @return \pwf\components\i18n\interfaces\Translator
[ "Get", "translator", "by", "type" ]
a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e
https://github.com/SergioMadness/framework/blob/a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e/framework/components/i18n/Fabric.php#L15-L69
train
broeser/sanitor
src/SanitizableTrait.php
SanitizableTrait.getFilteredValue
public function getFilteredValue() { if(!$this->getSanitizer() instanceof Sanitizer) { throw new \Exception('You have to assign a sanitizer first!'); } return $this->getSanitizer()->filter($this->getRawValue()); }
php
public function getFilteredValue() { if(!$this->getSanitizer() instanceof Sanitizer) { throw new \Exception('You have to assign a sanitizer first!'); } return $this->getSanitizer()->filter($this->getRawValue()); }
[ "public", "function", "getFilteredValue", "(", ")", "{", "if", "(", "!", "$", "this", "->", "getSanitizer", "(", ")", "instanceof", "Sanitizer", ")", "{", "throw", "new", "\\", "Exception", "(", "'You have to assign a sanitizer first!'", ")", ";", "}", "return...
Returns the filtered value of this @return mixed @throws Exception
[ "Returns", "the", "filtered", "value", "of", "this" ]
580e539a2747e3d66527cbbde968004743481a5c
https://github.com/broeser/sanitor/blob/580e539a2747e3d66527cbbde968004743481a5c/src/SanitizableTrait.php#L39-L45
train
bearframework/emails-addon
classes/Emails.php
Emails.send
public function send(\BearFramework\Emails\Email $email): void { $app = App::get(); $email = clone($email); if ($this->hasEventListeners('beforeSendEmail')) { $eventDetails = new \BearFramework\Emails\BeforeSendEmailEventDetails($email); $this->dispatchEvent('beforeSendEmail', $eventDetails); if ($eventDetails->preventDefault) { return; } } if (empty($this->senders)) { throw new \Exception('No email senders added.'); } foreach ($this->senders as $sender) { if (is_callable($sender)) { $sender = call_user_func($sender); } if (is_string($sender)) { $sender = new $sender(); } if ($sender instanceof \BearFramework\Emails\ISender) { if ($sender->send($email)) { if ($this->hasEventListeners('sendEmail')) { $eventDetails = new \BearFramework\Emails\SendEmailEventDetails($email); $this->dispatchEvent('sendEmail', $eventDetails); } return; } } } throw new \Exception('No email sender is capable of sending the email provided.'); }
php
public function send(\BearFramework\Emails\Email $email): void { $app = App::get(); $email = clone($email); if ($this->hasEventListeners('beforeSendEmail')) { $eventDetails = new \BearFramework\Emails\BeforeSendEmailEventDetails($email); $this->dispatchEvent('beforeSendEmail', $eventDetails); if ($eventDetails->preventDefault) { return; } } if (empty($this->senders)) { throw new \Exception('No email senders added.'); } foreach ($this->senders as $sender) { if (is_callable($sender)) { $sender = call_user_func($sender); } if (is_string($sender)) { $sender = new $sender(); } if ($sender instanceof \BearFramework\Emails\ISender) { if ($sender->send($email)) { if ($this->hasEventListeners('sendEmail')) { $eventDetails = new \BearFramework\Emails\SendEmailEventDetails($email); $this->dispatchEvent('sendEmail', $eventDetails); } return; } } } throw new \Exception('No email sender is capable of sending the email provided.'); }
[ "public", "function", "send", "(", "\\", "BearFramework", "\\", "Emails", "\\", "Email", "$", "email", ")", ":", "void", "{", "$", "app", "=", "App", "::", "get", "(", ")", ";", "$", "email", "=", "clone", "(", "$", "email", ")", ";", "if", "(", ...
Sends a email. @param \BearFramework\Emails\Email $email The email to send. @return void No value is returned. @throws \Exception
[ "Sends", "a", "email", "." ]
43a68c47e2b1d231dc69a324249ff5f6827201ca
https://github.com/bearframework/emails-addon/blob/43a68c47e2b1d231dc69a324249ff5f6827201ca/classes/Emails.php#L73-L108
train
treehouselabs/domain
src/TreeHouse/Domain/AbstractAggregate.php
AbstractAggregate.mutate
private function mutate($event) { $method = 'on' . (string) new EventName($event); if (method_exists($this, $method)) { $this->$method($event); } else { throw new \RuntimeException(sprintf('Method %s does not exist on aggregate %s', $method, get_class($this))); } }
php
private function mutate($event) { $method = 'on' . (string) new EventName($event); if (method_exists($this, $method)) { $this->$method($event); } else { throw new \RuntimeException(sprintf('Method %s does not exist on aggregate %s', $method, get_class($this))); } }
[ "private", "function", "mutate", "(", "$", "event", ")", "{", "$", "method", "=", "'on'", ".", "(", "string", ")", "new", "EventName", "(", "$", "event", ")", ";", "if", "(", "method_exists", "(", "$", "this", ",", "$", "method", ")", ")", "{", "...
Update in-memory state. @param object $event
[ "Update", "in", "-", "memory", "state", "." ]
e22b319307b985dcac94687b1c2b5418b41f1998
https://github.com/treehouselabs/domain/blob/e22b319307b985dcac94687b1c2b5418b41f1998/src/TreeHouse/Domain/AbstractAggregate.php#L14-L23
train
myerscode/utilities-numbers
src/Utility.php
Utility.divide
public function divide($number): Utility { $divisible = new static($number); if ($divisible->value() == 0 || $this->number == 0) { throw new DivisionByZeroError(); } $value = $this->number / $divisible->value(); return new static($value); }
php
public function divide($number): Utility { $divisible = new static($number); if ($divisible->value() == 0 || $this->number == 0) { throw new DivisionByZeroError(); } $value = $this->number / $divisible->value(); return new static($value); }
[ "public", "function", "divide", "(", "$", "number", ")", ":", "Utility", "{", "$", "divisible", "=", "new", "static", "(", "$", "number", ")", ";", "if", "(", "$", "divisible", "->", "value", "(", ")", "==", "0", "||", "$", "this", "->", "number", ...
Divide the number by the number @param $number @return Utility @throws NonNumericValueException @throws \DivisionByZeroError
[ "Divide", "the", "number", "by", "the", "number" ]
c2ee8bffcda5fda425572bc3e195e9afb795f843
https://github.com/myerscode/utilities-numbers/blob/c2ee8bffcda5fda425572bc3e195e9afb795f843/src/Utility.php#L95-L106
train
myerscode/utilities-numbers
src/Utility.php
Utility.factors
public function factors(): array { // 0 has infinite factors if ($this->number === 0 || !is_int($this->number)) { throw new InvalidNumberException(); } $x = abs($this->number); $sqrx = floor(sqrt($x)); $factors = []; for ($i = 1; $i <= $sqrx; $i++) { if ($x % $i === 0) { $factors[] = $i; if ($i !== $sqrx) { $factors[] = $x / $i; } } } sort($factors); return $factors; }
php
public function factors(): array { // 0 has infinite factors if ($this->number === 0 || !is_int($this->number)) { throw new InvalidNumberException(); } $x = abs($this->number); $sqrx = floor(sqrt($x)); $factors = []; for ($i = 1; $i <= $sqrx; $i++) { if ($x % $i === 0) { $factors[] = $i; if ($i !== $sqrx) { $factors[] = $x / $i; } } } sort($factors); return $factors; }
[ "public", "function", "factors", "(", ")", ":", "array", "{", "// 0 has infinite factors", "if", "(", "$", "this", "->", "number", "===", "0", "||", "!", "is_int", "(", "$", "this", "->", "number", ")", ")", "{", "throw", "new", "InvalidNumberException", ...
Get the factors for the number @return array @throws InvalidNumberException
[ "Get", "the", "factors", "for", "the", "number" ]
c2ee8bffcda5fda425572bc3e195e9afb795f843
https://github.com/myerscode/utilities-numbers/blob/c2ee8bffcda5fda425572bc3e195e9afb795f843/src/Utility.php#L114-L135
train
myerscode/utilities-numbers
src/Utility.php
Utility.isNegative
public function isNegative(): bool { if ($this->number === 0 ){ throw new IsZeroException('0 is neither positive or negative'); } return (!is_int($this->number) && $this->number < 0 || $this->number < 0); }
php
public function isNegative(): bool { if ($this->number === 0 ){ throw new IsZeroException('0 is neither positive or negative'); } return (!is_int($this->number) && $this->number < 0 || $this->number < 0); }
[ "public", "function", "isNegative", "(", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "number", "===", "0", ")", "{", "throw", "new", "IsZeroException", "(", "'0 is neither positive or negative'", ")", ";", "}", "return", "(", "!", "is_int", "(", ...
Is the number negative @return bool @throws IsZeroException
[ "Is", "the", "number", "negative" ]
c2ee8bffcda5fda425572bc3e195e9afb795f843
https://github.com/myerscode/utilities-numbers/blob/c2ee8bffcda5fda425572bc3e195e9afb795f843/src/Utility.php#L156-L162
train
myerscode/utilities-numbers
src/Utility.php
Utility.magnitude
public function magnitude(): Utility { if ($this->number == 0) { $magnitude = 0; } else { $magnitude = floor(log10(abs($this->number))); } return new static($magnitude); }
php
public function magnitude(): Utility { if ($this->number == 0) { $magnitude = 0; } else { $magnitude = floor(log10(abs($this->number))); } return new static($magnitude); }
[ "public", "function", "magnitude", "(", ")", ":", "Utility", "{", "if", "(", "$", "this", "->", "number", "==", "0", ")", "{", "$", "magnitude", "=", "0", ";", "}", "else", "{", "$", "magnitude", "=", "floor", "(", "log10", "(", "abs", "(", "$", ...
Get the order of magnitude of the number @return Utility @throws NonNumericValueException
[ "Get", "the", "order", "of", "magnitude", "of", "the", "number" ]
c2ee8bffcda5fda425572bc3e195e9afb795f843
https://github.com/myerscode/utilities-numbers/blob/c2ee8bffcda5fda425572bc3e195e9afb795f843/src/Utility.php#L183-L192
train
myerscode/utilities-numbers
src/Utility.php
Utility.pad
private function pad($padding = 1, $direction = STR_PAD_BOTH): string { return str_pad($this->number, $padding, 0, $direction); }
php
private function pad($padding = 1, $direction = STR_PAD_BOTH): string { return str_pad($this->number, $padding, 0, $direction); }
[ "private", "function", "pad", "(", "$", "padding", "=", "1", ",", "$", "direction", "=", "STR_PAD_BOTH", ")", ":", "string", "{", "return", "str_pad", "(", "$", "this", "->", "number", ",", "$", "padding", ",", "0", ",", "$", "direction", ")", ";", ...
Add padding to the number @param int $padding @param int $direction @return string
[ "Add", "padding", "to", "the", "number" ]
c2ee8bffcda5fda425572bc3e195e9afb795f843
https://github.com/myerscode/utilities-numbers/blob/c2ee8bffcda5fda425572bc3e195e9afb795f843/src/Utility.php#L259-L262
train
myerscode/utilities-numbers
src/Utility.php
Utility.round
private function round($number, $precision, int $mode): Utility { if ($precision < 0) { throw new InvalidNumberException('Precision value should be greater or equal to zero'); } $value = round($number, $precision, $mode); return new static($value); }
php
private function round($number, $precision, int $mode): Utility { if ($precision < 0) { throw new InvalidNumberException('Precision value should be greater or equal to zero'); } $value = round($number, $precision, $mode); return new static($value); }
[ "private", "function", "round", "(", "$", "number", ",", "$", "precision", ",", "int", "$", "mode", ")", ":", "Utility", "{", "if", "(", "$", "precision", "<", "0", ")", "{", "throw", "new", "InvalidNumberException", "(", "'Precision value should be greater ...
Round a number @param $number @param int $precision @param int $mode @return Utility @throws InvalidNumberException @throws NonNumericValueException
[ "Round", "a", "number" ]
c2ee8bffcda5fda425572bc3e195e9afb795f843
https://github.com/myerscode/utilities-numbers/blob/c2ee8bffcda5fda425572bc3e195e9afb795f843/src/Utility.php#L310-L319
train
myerscode/utilities-numbers
src/Utility.php
Utility.roundDown
public function roundDown(int $precision = 0): Utility { return $this->round($this->number, $precision, PHP_ROUND_HALF_DOWN); }
php
public function roundDown(int $precision = 0): Utility { return $this->round($this->number, $precision, PHP_ROUND_HALF_DOWN); }
[ "public", "function", "roundDown", "(", "int", "$", "precision", "=", "0", ")", ":", "Utility", "{", "return", "$", "this", "->", "round", "(", "$", "this", "->", "number", ",", "$", "precision", ",", "PHP_ROUND_HALF_DOWN", ")", ";", "}" ]
Round down the number @param int $precision @return Utility @throws InvalidNumberException @throws NonNumericValueException
[ "Round", "down", "the", "number" ]
c2ee8bffcda5fda425572bc3e195e9afb795f843
https://github.com/myerscode/utilities-numbers/blob/c2ee8bffcda5fda425572bc3e195e9afb795f843/src/Utility.php#L330-L333
train
myerscode/utilities-numbers
src/Utility.php
Utility.roundUp
public function roundUp(int $precision = 0): Utility { return $this->round($this->number, $precision, PHP_ROUND_HALF_UP); }
php
public function roundUp(int $precision = 0): Utility { return $this->round($this->number, $precision, PHP_ROUND_HALF_UP); }
[ "public", "function", "roundUp", "(", "int", "$", "precision", "=", "0", ")", ":", "Utility", "{", "return", "$", "this", "->", "round", "(", "$", "this", "->", "number", ",", "$", "precision", ",", "PHP_ROUND_HALF_UP", ")", ";", "}" ]
Round up the number @param int $precision @return Utility @throws InvalidNumberException @throws NonNumericValueException
[ "Round", "up", "the", "number" ]
c2ee8bffcda5fda425572bc3e195e9afb795f843
https://github.com/myerscode/utilities-numbers/blob/c2ee8bffcda5fda425572bc3e195e9afb795f843/src/Utility.php#L344-L347
train
nattreid/security
src/Model/Users/User.php
User.setUsername
public function setUsername(string $username): void { if (Strings::match($username, '/[^A-Za-z0-9_]/')) { throw new InvalidArgumentException('Username contains invalid characters'); } /* @var $repository UsersRepository */ $repository = $this->getRepository(); $user = $repository->getByUsername($username); if ($user !== null && $user !== $this) { throw new UniqueConstraintViolationException("Username '$username' exists"); } $this->username = $username; }
php
public function setUsername(string $username): void { if (Strings::match($username, '/[^A-Za-z0-9_]/')) { throw new InvalidArgumentException('Username contains invalid characters'); } /* @var $repository UsersRepository */ $repository = $this->getRepository(); $user = $repository->getByUsername($username); if ($user !== null && $user !== $this) { throw new UniqueConstraintViolationException("Username '$username' exists"); } $this->username = $username; }
[ "public", "function", "setUsername", "(", "string", "$", "username", ")", ":", "void", "{", "if", "(", "Strings", "::", "match", "(", "$", "username", ",", "'/[^A-Za-z0-9_]/'", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Username contains...
Ulozi uzivatelske jmeno @param string $username @throws UniqueConstraintViolationException @throws InvalidArgumentException
[ "Ulozi", "uzivatelske", "jmeno" ]
ed649e5bdf453cea2d5352e643dbf201193de01d
https://github.com/nattreid/security/blob/ed649e5bdf453cea2d5352e643dbf201193de01d/src/Model/Users/User.php#L65-L78
train
nattreid/security
src/Model/Users/User.php
User.getterRoleConstants
public function getterRoleConstants(): array { $result = []; $roles = $this->roles->get(); /* @var $role AclRole */ foreach ($roles as $role) { $result[] = $role->name; } return $result; }
php
public function getterRoleConstants(): array { $result = []; $roles = $this->roles->get(); /* @var $role AclRole */ foreach ($roles as $role) { $result[] = $role->name; } return $result; }
[ "public", "function", "getterRoleConstants", "(", ")", ":", "array", "{", "$", "result", "=", "[", "]", ";", "$", "roles", "=", "$", "this", "->", "roles", "->", "get", "(", ")", ";", "/* @var $role AclRole */", "foreach", "(", "$", "roles", "as", "$",...
Vrati jmena roli @return array
[ "Vrati", "jmena", "roli" ]
ed649e5bdf453cea2d5352e643dbf201193de01d
https://github.com/nattreid/security/blob/ed649e5bdf453cea2d5352e643dbf201193de01d/src/Model/Users/User.php#L136-L145
train
nattreid/security
src/Model/Users/User.php
User.getterRoleTitles
protected function getterRoleTitles(): array { $result = []; $roles = $this->roles->get(); /* @var $role AclRole */ foreach ($roles as $role) { $result[] = $role->title; } return $result; }
php
protected function getterRoleTitles(): array { $result = []; $roles = $this->roles->get(); /* @var $role AclRole */ foreach ($roles as $role) { $result[] = $role->title; } return $result; }
[ "protected", "function", "getterRoleTitles", "(", ")", ":", "array", "{", "$", "result", "=", "[", "]", ";", "$", "roles", "=", "$", "this", "->", "roles", "->", "get", "(", ")", ";", "/* @var $role AclRole */", "foreach", "(", "$", "roles", "as", "$",...
Vrati nazvy roli @return array
[ "Vrati", "nazvy", "roli" ]
ed649e5bdf453cea2d5352e643dbf201193de01d
https://github.com/nattreid/security/blob/ed649e5bdf453cea2d5352e643dbf201193de01d/src/Model/Users/User.php#L151-L160
train
jnjxp/html
src/Helper/Styles.php
Styles.inline
public function inline($style, array $attr = null) { $attr = $this->escaper->attr( $this->fixInlineAttr($attr) ); return "<style {$attr}>{$style}</style>"; }
php
public function inline($style, array $attr = null) { $attr = $this->escaper->attr( $this->fixInlineAttr($attr) ); return "<style {$attr}>{$style}</style>"; }
[ "public", "function", "inline", "(", "$", "style", ",", "array", "$", "attr", "=", "null", ")", "{", "$", "attr", "=", "$", "this", "->", "escaper", "->", "attr", "(", "$", "this", "->", "fixInlineAttr", "(", "$", "attr", ")", ")", ";", "return", ...
makes an internal style tag @param string $style css snippet @param null|array $attr attributes for style tag @return string @access public
[ "makes", "an", "internal", "style", "tag" ]
a38f130c19ab0a60ea52bc1d2560a68d2048d292
https://github.com/jnjxp/html/blob/a38f130c19ab0a60ea52bc1d2560a68d2048d292/src/Helper/Styles.php#L67-L73
train
jnjxp/html
src/Helper/Styles.php
Styles.inlineCond
public function inlineCond($cond, $style, array $attr = null) { $style = $this->inline($style, $attr); $cond = $this->escaper->html($cond); return "<!--[if {$cond}]>{$style}<![endif]-->"; }
php
public function inlineCond($cond, $style, array $attr = null) { $style = $this->inline($style, $attr); $cond = $this->escaper->html($cond); return "<!--[if {$cond}]>{$style}<![endif]-->"; }
[ "public", "function", "inlineCond", "(", "$", "cond", ",", "$", "style", ",", "array", "$", "attr", "=", "null", ")", "{", "$", "style", "=", "$", "this", "->", "inline", "(", "$", "style", ",", "$", "attr", ")", ";", "$", "cond", "=", "$", "th...
add inline conditional style @param string $cond ie condition @param string $style css snippet @param null|array $attr attributes for style tag @return string @access public
[ "add", "inline", "conditional", "style" ]
a38f130c19ab0a60ea52bc1d2560a68d2048d292
https://github.com/jnjxp/html/blob/a38f130c19ab0a60ea52bc1d2560a68d2048d292/src/Helper/Styles.php#L86-L91
train
jnjxp/html
src/Helper/Styles.php
Styles.addInline
public function addInline($style, array $attr = null, $position = 1000) { $this->addElement( $position, $this->inline($style, $attr) ); return $this; }
php
public function addInline($style, array $attr = null, $position = 1000) { $this->addElement( $position, $this->inline($style, $attr) ); return $this; }
[ "public", "function", "addInline", "(", "$", "style", ",", "array", "$", "attr", "=", "null", ",", "$", "position", "=", "1000", ")", "{", "$", "this", "->", "addElement", "(", "$", "position", ",", "$", "this", "->", "inline", "(", "$", "style", "...
add inline css @param string $style css snippet @param null|array $attr attributes for style tag @param int $position sort @return Styles @access public
[ "add", "inline", "css" ]
a38f130c19ab0a60ea52bc1d2560a68d2048d292
https://github.com/jnjxp/html/blob/a38f130c19ab0a60ea52bc1d2560a68d2048d292/src/Helper/Styles.php#L104-L111
train
jnjxp/html
src/Helper/Styles.php
Styles.addInlineCond
public function addInlineCond( $cond, $style, array $attr = null, $position = 1000 ) { $this->addElement( $position, $this->inlineCond($cond, $style, $attr) ); return $this; }
php
public function addInlineCond( $cond, $style, array $attr = null, $position = 1000 ) { $this->addElement( $position, $this->inlineCond($cond, $style, $attr) ); return $this; }
[ "public", "function", "addInlineCond", "(", "$", "cond", ",", "$", "style", ",", "array", "$", "attr", "=", "null", ",", "$", "position", "=", "1000", ")", "{", "$", "this", "->", "addElement", "(", "$", "position", ",", "$", "this", "->", "inlineCon...
add inline conditional css @param string $cond ie condition @param string $style css snippet @param null|array $attr attributes for style tag @param int $position sort @return Styles @access public
[ "add", "inline", "conditional", "css" ]
a38f130c19ab0a60ea52bc1d2560a68d2048d292
https://github.com/jnjxp/html/blob/a38f130c19ab0a60ea52bc1d2560a68d2048d292/src/Helper/Styles.php#L125-L136
train
jnjxp/html
src/Helper/Styles.php
Styles.inlineCaptureStart
public function inlineCaptureStart(array $attr = null, $position = 1000) { $this->capture[] = [ 'func' => 'addInline', 'args' => [ 'style' => '', $attr, $position ] ]; ob_start(); return $this; }
php
public function inlineCaptureStart(array $attr = null, $position = 1000) { $this->capture[] = [ 'func' => 'addInline', 'args' => [ 'style' => '', $attr, $position ] ]; ob_start(); return $this; }
[ "public", "function", "inlineCaptureStart", "(", "array", "$", "attr", "=", "null", ",", "$", "position", "=", "1000", ")", "{", "$", "this", "->", "capture", "[", "]", "=", "[", "'func'", "=>", "'addInline'", ",", "'args'", "=>", "[", "'style'", "=>",...
capture inline snippet @param null|array $attr attributes for style tag @param int $position sort @return Styles @access public
[ "capture", "inline", "snippet" ]
a38f130c19ab0a60ea52bc1d2560a68d2048d292
https://github.com/jnjxp/html/blob/a38f130c19ab0a60ea52bc1d2560a68d2048d292/src/Helper/Styles.php#L148-L161
train
jnjxp/html
src/Helper/Styles.php
Styles.inlineCondCaptureStart
public function inlineCondCaptureStart( $cond, array $attr = null, $position = 1000 ) { $this->capture[] = [ 'func' => 'addInlineCond', 'args' => [ $cond, 'style' => '', $attr, $position ] ]; ob_start(); return $this; }
php
public function inlineCondCaptureStart( $cond, array $attr = null, $position = 1000 ) { $this->capture[] = [ 'func' => 'addInlineCond', 'args' => [ $cond, 'style' => '', $attr, $position ] ]; ob_start(); return $this; }
[ "public", "function", "inlineCondCaptureStart", "(", "$", "cond", ",", "array", "$", "attr", "=", "null", ",", "$", "position", "=", "1000", ")", "{", "$", "this", "->", "capture", "[", "]", "=", "[", "'func'", "=>", "'addInlineCond'", ",", "'args'", "...
capture inline conditional style @param mixed $cond ie condition @param null|array $attr attributes for style tag @param int $position sort @return Styles @access public
[ "capture", "inline", "conditional", "style" ]
a38f130c19ab0a60ea52bc1d2560a68d2048d292
https://github.com/jnjxp/html/blob/a38f130c19ab0a60ea52bc1d2560a68d2048d292/src/Helper/Styles.php#L174-L191
train
bfitech/zapmin
src/AdminStoreTables.php
AdminStoreTables.init
public static function init(AdminStore $admin_store) { self::$admin_store = $admin_store; self::$sql = $admin_store->store; self::$logger = $admin_store->logger; }
php
public static function init(AdminStore $admin_store) { self::$admin_store = $admin_store; self::$sql = $admin_store->store; self::$logger = $admin_store->logger; }
[ "public", "static", "function", "init", "(", "AdminStore", "$", "admin_store", ")", "{", "self", "::", "$", "admin_store", "=", "$", "admin_store", ";", "self", "::", "$", "sql", "=", "$", "admin_store", "->", "store", ";", "self", "::", "$", "logger", ...
Initialize object. @param AdminStore $admin_store An instance of AdminStore.
[ "Initialize", "object", "." ]
4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe
https://github.com/bfitech/zapmin/blob/4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe/src/AdminStoreTables.php#L29-L33
train
bfitech/zapmin
src/AdminStoreTables.php
AdminStoreTables.drop
public static function drop() { foreach([ "DROP VIEW IF EXISTS v_usess", "DROP TABLE IF EXISTS usess", "DROP TABLE IF EXISTS udata", "DROP TABLE IF EXISTS meta", ] as $drop) { // @codeCoverageIgnoreStart try { self::$sql->query_raw($drop); } catch(SQLError $e) { $msg = "Cannot drop data:" . $e->getMessage(); self::$logger->error("Zapmin: sql error: $msg"); throw new AdminStoreError($msg); } // @codeCoverageIgnoreEnd } }
php
public static function drop() { foreach([ "DROP VIEW IF EXISTS v_usess", "DROP TABLE IF EXISTS usess", "DROP TABLE IF EXISTS udata", "DROP TABLE IF EXISTS meta", ] as $drop) { // @codeCoverageIgnoreStart try { self::$sql->query_raw($drop); } catch(SQLError $e) { $msg = "Cannot drop data:" . $e->getMessage(); self::$logger->error("Zapmin: sql error: $msg"); throw new AdminStoreError($msg); } // @codeCoverageIgnoreEnd } }
[ "public", "static", "function", "drop", "(", ")", "{", "foreach", "(", "[", "\"DROP VIEW IF EXISTS v_usess\"", ",", "\"DROP TABLE IF EXISTS usess\"", ",", "\"DROP TABLE IF EXISTS udata\"", ",", "\"DROP TABLE IF EXISTS meta\"", ",", "]", "as", "$", "drop", ")", "{", "/...
Drop existing tables.
[ "Drop", "existing", "tables", "." ]
4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe
https://github.com/bfitech/zapmin/blob/4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe/src/AdminStoreTables.php#L45-L62
train
bfitech/zapmin
src/AdminStoreTables.php
AdminStoreTables.exists
public static function exists($force_create_table=null) { $sql = self::$sql; $sql::$logger->deactivate(); try { $sql->query("SELECT 1 FROM udata LIMIT 1"); $sql::$logger->activate(); if ($force_create_table) { self::drop(); self::$logger->info("Zapmin: Recreating tables."); return false; } return true; } catch (SQLError $e) { } $sql::$logger->activate(); return false; }
php
public static function exists($force_create_table=null) { $sql = self::$sql; $sql::$logger->deactivate(); try { $sql->query("SELECT 1 FROM udata LIMIT 1"); $sql::$logger->activate(); if ($force_create_table) { self::drop(); self::$logger->info("Zapmin: Recreating tables."); return false; } return true; } catch (SQLError $e) { } $sql::$logger->activate(); return false; }
[ "public", "static", "function", "exists", "(", "$", "force_create_table", "=", "null", ")", "{", "$", "sql", "=", "self", "::", "$", "sql", ";", "$", "sql", "::", "$", "logger", "->", "deactivate", "(", ")", ";", "try", "{", "$", "sql", "->", "quer...
Check if tables exist. @param bool $force_create_table Recreate tables if true. @return bool True if tables exist.
[ "Check", "if", "tables", "exist", "." ]
4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe
https://github.com/bfitech/zapmin/blob/4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe/src/AdminStoreTables.php#L70-L86
train
bfitech/zapmin
src/AdminStoreTables.php
AdminStoreTables.fragments
public static function fragments($expiration=7200) { $sql = self::$sql; $args = []; $args['index'] = $sql->stmt_fragment('index'); $args['engine'] = $sql->stmt_fragment('engine'); $args['dtnow'] = $sql->stmt_fragment('datetime'); $args['expire'] = $sql->stmt_fragment( 'datetime', ['delta' => $expiration]); if ($sql->get_connection_params()['dbtype'] == 'mysql') $args['dtnow'] = $args['expire'] = 'CURRENT_TIMESTAMP'; return $args; }
php
public static function fragments($expiration=7200) { $sql = self::$sql; $args = []; $args['index'] = $sql->stmt_fragment('index'); $args['engine'] = $sql->stmt_fragment('engine'); $args['dtnow'] = $sql->stmt_fragment('datetime'); $args['expire'] = $sql->stmt_fragment( 'datetime', ['delta' => $expiration]); if ($sql->get_connection_params()['dbtype'] == 'mysql') $args['dtnow'] = $args['expire'] = 'CURRENT_TIMESTAMP'; return $args; }
[ "public", "static", "function", "fragments", "(", "$", "expiration", "=", "7200", ")", "{", "$", "sql", "=", "self", "::", "$", "sql", ";", "$", "args", "=", "[", "]", ";", "$", "args", "[", "'index'", "]", "=", "$", "sql", "->", "stmt_fragment", ...
SQL statement fragments. @param int $expiration Regular session expiration duration, in second.
[ "SQL", "statement", "fragments", "." ]
4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe
https://github.com/bfitech/zapmin/blob/4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe/src/AdminStoreTables.php#L94-L105
train
bfitech/zapmin
src/AdminStoreTables.php
AdminStoreTables.install
public static function install($expiration=7200) { $dtnow = $expire = null; extract(self::fragments($expiration)); $sql = self::$sql; # user table $user_table = (" CREATE TABLE udata ( uid %s, uname VARCHAR(64) UNIQUE, upass VARCHAR(64), usalt VARCHAR(16), since TIMESTAMP NOT NULL DEFAULT %s, email VARCHAR(64), email_verified INT NOT NULL DEFAULT 0, fname VARCHAR(128), site VARCHAR(128) ) %s; "); $user_table = sprintf($user_table, $index, $dtnow, $engine); $sql->query_raw($user_table); # default user $root_salt = self::$admin_store->generate_secret( 'root', null, 16); $root_pass = self::$admin_store->hash_password( 'root', 'admin', $root_salt); $sql->insert('udata', [ 'uid' => 1, 'uname' => 'root', 'upass' => $root_pass, 'usalt' => $root_salt, ]); # session table $session_table = (" CREATE TABLE usess ( sid %s, uid INTEGER REFERENCES udata(uid) ON DELETE CASCADE, token VARCHAR(64), expire TIMESTAMP NOT NULL DEFAULT %s ) %s; "); $session_table = sprintf( $session_table, $index, $expire, $engine); $sql->query_raw($session_table); # session view $user_session_view = (" CREATE VIEW v_usess AS SELECT udata.*, usess.sid, usess.token, usess.expire FROM udata, usess WHERE udata.uid=usess.uid; "); $sql->query_raw($user_session_view); # metadata $sql->query_raw(sprintf(" CREATE TABLE meta ( version VARCHAR(24) NOT NULL DEFAULT '0.0' ); ", $engine)); $sql->insert('meta', [ 'version' => self::TABLE_VERSION, ]); }
php
public static function install($expiration=7200) { $dtnow = $expire = null; extract(self::fragments($expiration)); $sql = self::$sql; # user table $user_table = (" CREATE TABLE udata ( uid %s, uname VARCHAR(64) UNIQUE, upass VARCHAR(64), usalt VARCHAR(16), since TIMESTAMP NOT NULL DEFAULT %s, email VARCHAR(64), email_verified INT NOT NULL DEFAULT 0, fname VARCHAR(128), site VARCHAR(128) ) %s; "); $user_table = sprintf($user_table, $index, $dtnow, $engine); $sql->query_raw($user_table); # default user $root_salt = self::$admin_store->generate_secret( 'root', null, 16); $root_pass = self::$admin_store->hash_password( 'root', 'admin', $root_salt); $sql->insert('udata', [ 'uid' => 1, 'uname' => 'root', 'upass' => $root_pass, 'usalt' => $root_salt, ]); # session table $session_table = (" CREATE TABLE usess ( sid %s, uid INTEGER REFERENCES udata(uid) ON DELETE CASCADE, token VARCHAR(64), expire TIMESTAMP NOT NULL DEFAULT %s ) %s; "); $session_table = sprintf( $session_table, $index, $expire, $engine); $sql->query_raw($session_table); # session view $user_session_view = (" CREATE VIEW v_usess AS SELECT udata.*, usess.sid, usess.token, usess.expire FROM udata, usess WHERE udata.uid=usess.uid; "); $sql->query_raw($user_session_view); # metadata $sql->query_raw(sprintf(" CREATE TABLE meta ( version VARCHAR(24) NOT NULL DEFAULT '0.0' ); ", $engine)); $sql->insert('meta', [ 'version' => self::TABLE_VERSION, ]); }
[ "public", "static", "function", "install", "(", "$", "expiration", "=", "7200", ")", "{", "$", "dtnow", "=", "$", "expire", "=", "null", ";", "extract", "(", "self", "::", "fragments", "(", "$", "expiration", ")", ")", ";", "$", "sql", "=", "self", ...
Install tables. @param int $expiration Regular session expiration duration, in second. @note In case of email addresses: - Unique and null in one column is not portable. Must check email uniqueness manually. - Email verification must be held separately. Table only reserves a column for it.
[ "Install", "tables", "." ]
4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe
https://github.com/bfitech/zapmin/blob/4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe/src/AdminStoreTables.php#L118-L194
train
bfitech/zapmin
src/AdminStoreTables.php
AdminStoreTables.upgrade
public static function upgrade() { $sql = self::$sql; $sql::$logger->deactivate(); try { $version = $sql->query( "SELECT version FROM meta LIMIT 1")['version']; } catch(SQLError $e) { $sql::$logger->activate(); return self::upgrade_tables(); } $sql::$logger->activate(); if (0 <= version_compare($version, self::TABLE_VERSION)) return self::$logger->debug( "Zapmin: Tables are up-to-date."); return self::upgrade_tables($version); }
php
public static function upgrade() { $sql = self::$sql; $sql::$logger->deactivate(); try { $version = $sql->query( "SELECT version FROM meta LIMIT 1")['version']; } catch(SQLError $e) { $sql::$logger->activate(); return self::upgrade_tables(); } $sql::$logger->activate(); if (0 <= version_compare($version, self::TABLE_VERSION)) return self::$logger->debug( "Zapmin: Tables are up-to-date."); return self::upgrade_tables($version); }
[ "public", "static", "function", "upgrade", "(", ")", "{", "$", "sql", "=", "self", "::", "$", "sql", ";", "$", "sql", "::", "$", "logger", "->", "deactivate", "(", ")", ";", "try", "{", "$", "version", "=", "$", "sql", "->", "query", "(", "\"SELE...
Check if tables need upgrade.
[ "Check", "if", "tables", "need", "upgrade", "." ]
4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe
https://github.com/bfitech/zapmin/blob/4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe/src/AdminStoreTables.php#L199-L217
train
bfitech/zapmin
src/AdminStoreTables.php
AdminStoreTables.upgrade_tables
private static function upgrade_tables($from_version=null) { $sql = self::$sql; if (!$from_version) { $from_version = '0.0'; $sql->query_raw(" CREATE TABLE meta ( version VARCHAR(24) NOT NULL DEFAULT '0.0' ); "); $sql->insert('meta', [ 'version' => self::TABLE_VERSION, ]); } else { $sql->update('meta', [ 'version' => self::TABLE_VERSION, ]); } self::$logger->info(sprintf( "Zapmin: Upgrading tables: '%s' -> '%s'.", $from_version, self::TABLE_VERSION)); # other upgrade actions here ... }
php
private static function upgrade_tables($from_version=null) { $sql = self::$sql; if (!$from_version) { $from_version = '0.0'; $sql->query_raw(" CREATE TABLE meta ( version VARCHAR(24) NOT NULL DEFAULT '0.0' ); "); $sql->insert('meta', [ 'version' => self::TABLE_VERSION, ]); } else { $sql->update('meta', [ 'version' => self::TABLE_VERSION, ]); } self::$logger->info(sprintf( "Zapmin: Upgrading tables: '%s' -> '%s'.", $from_version, self::TABLE_VERSION)); # other upgrade actions here ... }
[ "private", "static", "function", "upgrade_tables", "(", "$", "from_version", "=", "null", ")", "{", "$", "sql", "=", "self", "::", "$", "sql", ";", "if", "(", "!", "$", "from_version", ")", "{", "$", "from_version", "=", "'0.0'", ";", "$", "sql", "->...
Upgrade tables.
[ "Upgrade", "tables", "." ]
4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe
https://github.com/bfitech/zapmin/blob/4aebbe0e727328a9632f80b2e6ba4aef6a2fabfe/src/AdminStoreTables.php#L222-L247
train
affinity4/config
src/Loader/Json.php
Json.input
public function input($file_content) { $this->file_content = $file_content; $this->parsed_content = json_decode($this->file_content, true); }
php
public function input($file_content) { $this->file_content = $file_content; $this->parsed_content = json_decode($this->file_content, true); }
[ "public", "function", "input", "(", "$", "file_content", ")", "{", "$", "this", "->", "file_content", "=", "$", "file_content", ";", "$", "this", "->", "parsed_content", "=", "json_decode", "(", "$", "this", "->", "file_content", ",", "true", ")", ";", "...
Get raw JSON content and convert to array using json_decode @author Luke Watts <luke@affinity4.ie> @since 1.1.0 @param $file_content string @return void
[ "Get", "raw", "JSON", "content", "and", "convert", "to", "array", "using", "json_decode" ]
df25bbf0839626af9b70b885e28bf32b1ad8d94a
https://github.com/affinity4/config/blob/df25bbf0839626af9b70b885e28bf32b1ad8d94a/src/Loader/Json.php#L59-L64
train
routegroup/native-media
src/Traits/Fileable.php
Fileable.files
public function files() { return $this->morphToMany( config('media.model', \Routegroup\Media\File::class), 'mediables', null, null, 'media_id' ) ->withPivot('type') ->whereNotNull('mediables.type') ->withTimestamps(); }
php
public function files() { return $this->morphToMany( config('media.model', \Routegroup\Media\File::class), 'mediables', null, null, 'media_id' ) ->withPivot('type') ->whereNotNull('mediables.type') ->withTimestamps(); }
[ "public", "function", "files", "(", ")", "{", "return", "$", "this", "->", "morphToMany", "(", "config", "(", "'media.model'", ",", "\\", "Routegroup", "\\", "Media", "\\", "File", "::", "class", ")", ",", "'mediables'", ",", "null", ",", "null", ",", ...
Has many files. @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
[ "Has", "many", "files", "." ]
5ea35c46c2ac1019e277ec4fe698f17581524631
https://github.com/routegroup/native-media/blob/5ea35c46c2ac1019e277ec4fe698f17581524631/src/Traits/Fileable.php#L32-L44
train
asbsoft/yii2module-users_0_170112
models/User.php
User.profileRules
public function profileRules() { return [ [['username', 'password', 'email'], 'required', 'on' => self::SCENARIO_CREATE], ['username', 'match', 'pattern' => '/^[A-Za-z][A-Za-z0-9\-\.\ ]+$/i', 'message' => Yii::t($this->tcModule, 'Only latin letters, digits, hyphen, points and blanks begin with letter') ], ['username', 'string', 'min' => $this->minUsernameLength, 'max' => $this->maxUsernameLength], ['password', 'string', 'min' => $this->minPasswordLength, 'max' => $this->maxPasswordLength], ['email', 'string', 'max' => 255], ['email', 'email'], ]; }
php
public function profileRules() { return [ [['username', 'password', 'email'], 'required', 'on' => self::SCENARIO_CREATE], ['username', 'match', 'pattern' => '/^[A-Za-z][A-Za-z0-9\-\.\ ]+$/i', 'message' => Yii::t($this->tcModule, 'Only latin letters, digits, hyphen, points and blanks begin with letter') ], ['username', 'string', 'min' => $this->minUsernameLength, 'max' => $this->maxUsernameLength], ['password', 'string', 'min' => $this->minPasswordLength, 'max' => $this->maxPasswordLength], ['email', 'string', 'max' => 255], ['email', 'email'], ]; }
[ "public", "function", "profileRules", "(", ")", "{", "return", "[", "[", "[", "'username'", ",", "'password'", ",", "'email'", "]", ",", "'required'", ",", "'on'", "=>", "self", "::", "SCENARIO_CREATE", "]", ",", "[", "'username'", ",", "'match'", ",", "...
Part of rules for common use with ProfileForm. Rules with fields length, patterns be best in single place.
[ "Part", "of", "rules", "for", "common", "use", "with", "ProfileForm", ".", "Rules", "with", "fields", "length", "patterns", "be", "best", "in", "single", "place", "." ]
3906fdde2d5fdd54637f2b5246d52fe91ec5f648
https://github.com/asbsoft/yii2module-users_0_170112/blob/3906fdde2d5fdd54637f2b5246d52fe91ec5f648/models/User.php#L107-L122
train
bytorsten/graphql-subscriptions
src/Rules/SingleFieldSubscriptions.php
SingleFieldSubscriptions.getVisitor
public function getVisitor(ValidationContext $context) { return [ NodeKind::OPERATION_DEFINITION => function (OperationDefinitionNode $node) use ($context) { if ($node->operation === 'subscription') { if (count($node->selectionSet->selections) !== 1) { $context->reportError( new Error( $this->singleFieldOnlyMessage($node->name ? $node->name->value : null), array_slice($node->selectionSet->selections, 1) ) ); } } } ]; }
php
public function getVisitor(ValidationContext $context) { return [ NodeKind::OPERATION_DEFINITION => function (OperationDefinitionNode $node) use ($context) { if ($node->operation === 'subscription') { if (count($node->selectionSet->selections) !== 1) { $context->reportError( new Error( $this->singleFieldOnlyMessage($node->name ? $node->name->value : null), array_slice($node->selectionSet->selections, 1) ) ); } } } ]; }
[ "public", "function", "getVisitor", "(", "ValidationContext", "$", "context", ")", "{", "return", "[", "NodeKind", "::", "OPERATION_DEFINITION", "=>", "function", "(", "OperationDefinitionNode", "$", "node", ")", "use", "(", "$", "context", ")", "{", "if", "("...
Returns structure suitable for GraphQL\Language\Visitor @see \GraphQL\Language\Visitor @param ValidationContext $context @return array
[ "Returns", "structure", "suitable", "for", "GraphQL", "\\", "Language", "\\", "Visitor" ]
c47b40c0c1762439573029cfef49fee5a6ca7a08
https://github.com/bytorsten/graphql-subscriptions/blob/c47b40c0c1762439573029cfef49fee5a6ca7a08/src/Rules/SingleFieldSubscriptions.php#L28-L44
train
gossi/trixionary
src/TrixionaryModule.php
TrixionaryModule.getSkillsPath
public function getSkillsPath(Sport $sport) { return $this->getSportPath($sport)->append($this->getSkillsSegment($sport)); }
php
public function getSkillsPath(Sport $sport) { return $this->getSportPath($sport)->append($this->getSkillsSegment($sport)); }
[ "public", "function", "getSkillsPath", "(", "Sport", "$", "sport", ")", "{", "return", "$", "this", "->", "getSportPath", "(", "$", "sport", ")", "->", "append", "(", "$", "this", "->", "getSkillsSegment", "(", "$", "sport", ")", ")", ";", "}" ]
Returns the path for skills for the given sport @param Sport $sport @return Path
[ "Returns", "the", "path", "for", "skills", "for", "the", "given", "sport" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/TrixionaryModule.php#L150-L152
train
gossi/trixionary
src/TrixionaryModule.php
TrixionaryModule.getSkillPath
public function getSkillPath(Skill $skill) { return $this->getSkillsPath($skill->getSport())->append($this->getSkillSegment($skill)); }
php
public function getSkillPath(Skill $skill) { return $this->getSkillsPath($skill->getSport())->append($this->getSkillSegment($skill)); }
[ "public", "function", "getSkillPath", "(", "Skill", "$", "skill", ")", "{", "return", "$", "this", "->", "getSkillsPath", "(", "$", "skill", "->", "getSport", "(", ")", ")", "->", "append", "(", "$", "this", "->", "getSkillSegment", "(", "$", "skill", ...
Returns the path for the given skill @param Skill $skill @return Path
[ "Returns", "the", "path", "for", "the", "given", "skill" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/TrixionaryModule.php#L178-L180
train
gossi/trixionary
src/TrixionaryModule.php
TrixionaryModule.getSkillUrl
public function getSkillUrl(Skill $skill) { return $this->getSkillsUrl($skill->getSport()) . '/' . $this->getSkillSegment($skill); }
php
public function getSkillUrl(Skill $skill) { return $this->getSkillsUrl($skill->getSport()) . '/' . $this->getSkillSegment($skill); }
[ "public", "function", "getSkillUrl", "(", "Skill", "$", "skill", ")", "{", "return", "$", "this", "->", "getSkillsUrl", "(", "$", "skill", "->", "getSport", "(", ")", ")", ".", "'/'", ".", "$", "this", "->", "getSkillSegment", "(", "$", "skill", ")", ...
Returns the url for the given skill @param Skill $skill @return string
[ "Returns", "the", "url", "for", "the", "given", "skill" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/TrixionaryModule.php#L187-L189
train
samurai-fw/samurai
src/Console/Controller/UtilityController.php
UtilityController.locatorAction
public function locatorAction() { $arg = $this->request->get('args'); // task execute. if (($task = $this->request->get('tasks')) || ($task = $this->request->get('option.T'))) { return [self::FORWARD_ACTION, 'task.list']; } elseif ($this->isTask($arg)) { return [self::FORWARD_ACTION, 'task.execute']; } // start server. if ($arg === 's') { return [self::FORWARD_ACTION, 'utility.server']; } // show version. if ($arg === null && ($this->request->get('option.v') || $this->request->get('version'))) { return [self::FORWARD_ACTION, 'utility.version']; } // show usage. if ($arg === null) { return [self::FORWARD_ACTION, 'utility.usage']; } // action execute. // exclude first argument, because this is command name. $args = $this->request->getAsArray('args'); array_shift($args); $this->request->set('args', $args); return [self::FORWARD_ACTION, $this->completionActionArg($arg)]; }
php
public function locatorAction() { $arg = $this->request->get('args'); // task execute. if (($task = $this->request->get('tasks')) || ($task = $this->request->get('option.T'))) { return [self::FORWARD_ACTION, 'task.list']; } elseif ($this->isTask($arg)) { return [self::FORWARD_ACTION, 'task.execute']; } // start server. if ($arg === 's') { return [self::FORWARD_ACTION, 'utility.server']; } // show version. if ($arg === null && ($this->request->get('option.v') || $this->request->get('version'))) { return [self::FORWARD_ACTION, 'utility.version']; } // show usage. if ($arg === null) { return [self::FORWARD_ACTION, 'utility.usage']; } // action execute. // exclude first argument, because this is command name. $args = $this->request->getAsArray('args'); array_shift($args); $this->request->set('args', $args); return [self::FORWARD_ACTION, $this->completionActionArg($arg)]; }
[ "public", "function", "locatorAction", "(", ")", "{", "$", "arg", "=", "$", "this", "->", "request", "->", "get", "(", "'args'", ")", ";", "// task execute.", "if", "(", "(", "$", "task", "=", "$", "this", "->", "request", "->", "get", "(", "'tasks'"...
action locator action.
[ "action", "locator", "action", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Console/Controller/UtilityController.php#L51-L83
train
samurai-fw/samurai
src/Console/Controller/UtilityController.php
UtilityController.versionAction
public function versionAction() { $this->assign('version', Samurai::getVersion()); $this->assign('state', Samurai::getState()); return self::VIEW_TEMPLATE; }
php
public function versionAction() { $this->assign('version', Samurai::getVersion()); $this->assign('state', Samurai::getState()); return self::VIEW_TEMPLATE; }
[ "public", "function", "versionAction", "(", ")", "{", "$", "this", "->", "assign", "(", "'version'", ",", "Samurai", "::", "getVersion", "(", ")", ")", ";", "$", "this", "->", "assign", "(", "'state'", ",", "Samurai", "::", "getState", "(", ")", ")", ...
show version action.
[ "show", "version", "action", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Console/Controller/UtilityController.php#L90-L95
train
samurai-fw/samurai
src/Console/Controller/UtilityController.php
UtilityController.usageAction
public function usageAction() { $this->assign('version', Samurai::getVersion()); $this->assign('state', Samurai::getState()); $this->assign('script', './app'); // TODO: $this->request->getScript() return self::VIEW_TEMPLATE; }
php
public function usageAction() { $this->assign('version', Samurai::getVersion()); $this->assign('state', Samurai::getState()); $this->assign('script', './app'); // TODO: $this->request->getScript() return self::VIEW_TEMPLATE; }
[ "public", "function", "usageAction", "(", ")", "{", "$", "this", "->", "assign", "(", "'version'", ",", "Samurai", "::", "getVersion", "(", ")", ")", ";", "$", "this", "->", "assign", "(", "'state'", ",", "Samurai", "::", "getState", "(", ")", ")", "...
show usage action.
[ "show", "usage", "action", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Console/Controller/UtilityController.php#L101-L107
train
samurai-fw/samurai
src/Console/Controller/UtilityController.php
UtilityController.serverAction
public function serverAction() { chdir($this->application->config('directory.document_root')); $host = $this->request->get('host', 'localhost'); $port = $this->request->get('port', 8888); passthru(sprintf('php -S %s:%s index.php', $host, $port)); }
php
public function serverAction() { chdir($this->application->config('directory.document_root')); $host = $this->request->get('host', 'localhost'); $port = $this->request->get('port', 8888); passthru(sprintf('php -S %s:%s index.php', $host, $port)); }
[ "public", "function", "serverAction", "(", ")", "{", "chdir", "(", "$", "this", "->", "application", "->", "config", "(", "'directory.document_root'", ")", ")", ";", "$", "host", "=", "$", "this", "->", "request", "->", "get", "(", "'host'", ",", "'local...
start server action.
[ "start", "server", "action", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Console/Controller/UtilityController.php#L113-L119
train
JaredClemence/binn
src/builders/KeyValueByteGenerator.php
KeyValueByteGenerator.readNextKeyValuePair
public function readNextKeyValuePair( $truncatedString ) : ContainerElement { $keyBytes = $this->extractKeyBytes( $truncatedString ); $remainingBytes = substr( $truncatedString, $keyBytes->getLength() ); $data = $this->readData( $remainingBytes ); return new ContainerElement($keyBytes, $data); }
php
public function readNextKeyValuePair( $truncatedString ) : ContainerElement { $keyBytes = $this->extractKeyBytes( $truncatedString ); $remainingBytes = substr( $truncatedString, $keyBytes->getLength() ); $data = $this->readData( $remainingBytes ); return new ContainerElement($keyBytes, $data); }
[ "public", "function", "readNextKeyValuePair", "(", "$", "truncatedString", ")", ":", "ContainerElement", "{", "$", "keyBytes", "=", "$", "this", "->", "extractKeyBytes", "(", "$", "truncatedString", ")", ";", "$", "remainingBytes", "=", "substr", "(", "$", "tr...
This method receives a data string that is already truncated. The expectation is that the first bytes will represent the key, then a series of bytes will represent the value. That value will end either at the beginning of the next data structure or the end of the data string. @param type $truncatedString
[ "This", "method", "receives", "a", "data", "string", "that", "is", "already", "truncated", ".", "The", "expectation", "is", "that", "the", "first", "bytes", "will", "represent", "the", "key", "then", "a", "series", "of", "bytes", "will", "represent", "the", ...
838591e7a92c0f257c09a1df141d80737a20f7d9
https://github.com/JaredClemence/binn/blob/838591e7a92c0f257c09a1df141d80737a20f7d9/src/builders/KeyValueByteGenerator.php#L53-L58
train
romanmatyus/FileMailer
src/FileMailer/FileMailer.php
FileMailer.send
public function send(Message $message) { $content = $message->generateMessage(); preg_match('~Message-ID: <(?<message_id>\w+)[^>]+>~', $content, $matches); $path = $this->tempDir . '/'. $this->prefix . $matches['message_id'] . '.' . self::FILE_EXTENSION; if (($bytes = file_put_contents($path, $content)) === FALSE) { throw new InvalidStateException("Unable to write email to '$path'."); } return $bytes; }
php
public function send(Message $message) { $content = $message->generateMessage(); preg_match('~Message-ID: <(?<message_id>\w+)[^>]+>~', $content, $matches); $path = $this->tempDir . '/'. $this->prefix . $matches['message_id'] . '.' . self::FILE_EXTENSION; if (($bytes = file_put_contents($path, $content)) === FALSE) { throw new InvalidStateException("Unable to write email to '$path'."); } return $bytes; }
[ "public", "function", "send", "(", "Message", "$", "message", ")", "{", "$", "content", "=", "$", "message", "->", "generateMessage", "(", ")", ";", "preg_match", "(", "'~Message-ID: <(?<message_id>\\w+)[^>]+>~'", ",", "$", "content", ",", "$", "matches", ")",...
Store mail to file. @param Message $message @return int
[ "Store", "mail", "to", "file", "." ]
732685f5505ea764fe76cc92bc4ffbc3b4ea917b
https://github.com/romanmatyus/FileMailer/blob/732685f5505ea764fe76cc92bc4ffbc3b4ea917b/src/FileMailer/FileMailer.php#L66-L78
train
ytubes/videos
controllers/CategoryController.php
CategoryController.actionIndex
public function actionIndex($slug, $page = 1, $sort = '') { $this->trigger(self::EVENT_BEFORE_CATEGORY_SHOW); $data['slug'] = $slug; $data['sort'] = $sort; $data['page'] = (int) $page; $data['route'] = '/' . $this->getRoute(); // Ищем категорию $data['category'] = CategoryFinder::findBySlug($slug);//$categriesRepository->findBySlug($slug); if (empty($data['category'])) { throw new NotFoundHttpException('The requested page does not exist.'); } $videoFinder = new VideoFinder(); $data['videos'] = $videoFinder->getVideosFromCategory($data['category'], $page); $pagination = new Pagination([ 'totalCount' => $videoFinder->totalCount(), 'defaultPageSize' => Module::getInstance()->settings->get('items_per_page', 20), 'pageSize' => Module::getInstance()->settings->get('items_per_page', 20), 'route' => $data['route'], 'forcePageParam' => false, ]); $settings = Yii::$app->settings->getAll(); $settings['videos'] = Module::getInstance()->settings->getAll(); Event::on(self::class, self::EVENT_AFTER_CATEGORY_SHOW, [\ytubes\videos\events\UpdateCountersEvent::class, 'onShowThumbs'], $data); $this->trigger(self::EVENT_AFTER_CATEGORY_SHOW); return $this->render('category_videos', [ 'data' => $data, 'settings' => $settings, 'pagination' => $pagination, ]); }
php
public function actionIndex($slug, $page = 1, $sort = '') { $this->trigger(self::EVENT_BEFORE_CATEGORY_SHOW); $data['slug'] = $slug; $data['sort'] = $sort; $data['page'] = (int) $page; $data['route'] = '/' . $this->getRoute(); // Ищем категорию $data['category'] = CategoryFinder::findBySlug($slug);//$categriesRepository->findBySlug($slug); if (empty($data['category'])) { throw new NotFoundHttpException('The requested page does not exist.'); } $videoFinder = new VideoFinder(); $data['videos'] = $videoFinder->getVideosFromCategory($data['category'], $page); $pagination = new Pagination([ 'totalCount' => $videoFinder->totalCount(), 'defaultPageSize' => Module::getInstance()->settings->get('items_per_page', 20), 'pageSize' => Module::getInstance()->settings->get('items_per_page', 20), 'route' => $data['route'], 'forcePageParam' => false, ]); $settings = Yii::$app->settings->getAll(); $settings['videos'] = Module::getInstance()->settings->getAll(); Event::on(self::class, self::EVENT_AFTER_CATEGORY_SHOW, [\ytubes\videos\events\UpdateCountersEvent::class, 'onShowThumbs'], $data); $this->trigger(self::EVENT_AFTER_CATEGORY_SHOW); return $this->render('category_videos', [ 'data' => $data, 'settings' => $settings, 'pagination' => $pagination, ]); }
[ "public", "function", "actionIndex", "(", "$", "slug", ",", "$", "page", "=", "1", ",", "$", "sort", "=", "''", ")", "{", "$", "this", "->", "trigger", "(", "self", "::", "EVENT_BEFORE_CATEGORY_SHOW", ")", ";", "$", "data", "[", "'slug'", "]", "=", ...
Lists categorized Videos models. @return mixed
[ "Lists", "categorized", "Videos", "models", "." ]
a35ecb1f8e38381063fbd757683a13df3a8cbc48
https://github.com/ytubes/videos/blob/a35ecb1f8e38381063fbd757683a13df3a8cbc48/controllers/CategoryController.php#L56-L95
train
khooz/commons
src/MrAudioGuy/Commons/Arr.php
Arr.pluck
public static function pluck (array $array, $keys) { if (!is_array($keys)) { $keys = func_get_args(); array_shift($keys); } return array_intersect_key($array, array_flip($keys)); }
php
public static function pluck (array $array, $keys) { if (!is_array($keys)) { $keys = func_get_args(); array_shift($keys); } return array_intersect_key($array, array_flip($keys)); }
[ "public", "static", "function", "pluck", "(", "array", "$", "array", ",", "$", "keys", ")", "{", "if", "(", "!", "is_array", "(", "$", "keys", ")", ")", "{", "$", "keys", "=", "func_get_args", "(", ")", ";", "array_shift", "(", "$", "keys", ")", ...
Plucks keys from an array @param array $array @param $keys @return array
[ "Plucks", "keys", "from", "an", "array" ]
d426df97075e66e19f7576e89bdd954c699914f4
https://github.com/khooz/commons/blob/d426df97075e66e19f7576e89bdd954c699914f4/src/MrAudioGuy/Commons/Arr.php#L20-L29
train
khooz/commons
src/MrAudioGuy/Commons/Arr.php
Arr.is_associative
public static function is_associative (array $array) { foreach ($array as $k => $v) { $t = str_replace((int)$k, '', $k); if (!empty($t)) { if (!static::is_int($k)) { return true; } } } return false; }
php
public static function is_associative (array $array) { foreach ($array as $k => $v) { $t = str_replace((int)$k, '', $k); if (!empty($t)) { if (!static::is_int($k)) { return true; } } } return false; }
[ "public", "static", "function", "is_associative", "(", "array", "$", "array", ")", "{", "foreach", "(", "$", "array", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "t", "=", "str_replace", "(", "(", "int", ")", "$", "k", ",", "''", ",", "$", "...
Determines if an array is associative @param array $array @return bool
[ "Determines", "if", "an", "array", "is", "associative" ]
d426df97075e66e19f7576e89bdd954c699914f4
https://github.com/khooz/commons/blob/d426df97075e66e19f7576e89bdd954c699914f4/src/MrAudioGuy/Commons/Arr.php#L57-L72
train
jsiefer/class-mocker
src/ClassMocker.php
ClassMocker.enable
public function enable() { spl_autoload_register([$this, 'autoload'], true, true); spl_autoload_register([$this, 'autoloadOptional'], true, false); return $this; }
php
public function enable() { spl_autoload_register([$this, 'autoload'], true, true); spl_autoload_register([$this, 'autoloadOptional'], true, false); return $this; }
[ "public", "function", "enable", "(", ")", "{", "spl_autoload_register", "(", "[", "$", "this", ",", "'autoload'", "]", ",", "true", ",", "true", ")", ";", "spl_autoload_register", "(", "[", "$", "this", ",", "'autoloadOptional'", "]", ",", "true", ",", "...
Enable class mocker by registering the auto loader @return $this
[ "Enable", "class", "mocker", "by", "registering", "the", "auto", "loader" ]
a355fc9bece8e6f27fbfd09b1631234f7d73a791
https://github.com/jsiefer/class-mocker/blob/a355fc9bece8e6f27fbfd09b1631234f7d73a791/src/ClassMocker.php#L68-L73
train
jsiefer/class-mocker
src/ClassMocker.php
ClassMocker.mock
public function mock($pattern, $ifNotExist = false) { if ($ifNotExist) { $this->_optionalMockPatterns[] = $pattern; } else { $this->_mockPatterns[] = $pattern; } return $this; }
php
public function mock($pattern, $ifNotExist = false) { if ($ifNotExist) { $this->_optionalMockPatterns[] = $pattern; } else { $this->_mockPatterns[] = $pattern; } return $this; }
[ "public", "function", "mock", "(", "$", "pattern", ",", "$", "ifNotExist", "=", "false", ")", "{", "if", "(", "$", "ifNotExist", ")", "{", "$", "this", "->", "_optionalMockPatterns", "[", "]", "=", "$", "pattern", ";", "}", "else", "{", "$", "this", ...
Mock any class matching the given pattern e.g. mock('Mage*') mock('Mage*Collection') mock('Foo\Bar\*') @param string $pattern @param bool $ifNotExist @return $this
[ "Mock", "any", "class", "matching", "the", "given", "pattern" ]
a355fc9bece8e6f27fbfd09b1631234f7d73a791
https://github.com/jsiefer/class-mocker/blob/a355fc9bece8e6f27fbfd09b1631234f7d73a791/src/ClassMocker.php#L114-L123
train
jsiefer/class-mocker
src/ClassMocker.php
ClassMocker.generateAndLoadClass
public function generateAndLoadClass($className) { if (class_exists($className, false)) { throw new \RuntimeException("Unable to generate and load already existing class '$className'"); } $filename = $this->findFile($className); if (!$filename || !file_exists($filename)) { $classFileGenerator = $this->_builder->build($className); if ($filename) { file_put_contents($filename, $classFileGenerator->generate()); } else { $this->evalContent($classFileGenerator); } } if ($filename && file_exists($filename)) { include $filename; } }
php
public function generateAndLoadClass($className) { if (class_exists($className, false)) { throw new \RuntimeException("Unable to generate and load already existing class '$className'"); } $filename = $this->findFile($className); if (!$filename || !file_exists($filename)) { $classFileGenerator = $this->_builder->build($className); if ($filename) { file_put_contents($filename, $classFileGenerator->generate()); } else { $this->evalContent($classFileGenerator); } } if ($filename && file_exists($filename)) { include $filename; } }
[ "public", "function", "generateAndLoadClass", "(", "$", "className", ")", "{", "if", "(", "class_exists", "(", "$", "className", ",", "false", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"Unable to generate and load already existing class '$classNa...
Generate and load the given class @param string $className @throws \Exception @return void
[ "Generate", "and", "load", "the", "given", "class" ]
a355fc9bece8e6f27fbfd09b1631234f7d73a791
https://github.com/jsiefer/class-mocker/blob/a355fc9bece8e6f27fbfd09b1631234f7d73a791/src/ClassMocker.php#L215-L235
train
jsiefer/class-mocker
src/ClassMocker.php
ClassMocker._autoload
protected function _autoload($patterns, $className) { foreach ($patterns as $pattern) { if (!fnmatch($pattern, $className, FNM_NOESCAPE)) { continue; } $this->generateAndLoadClass($className); return true; } return false; }
php
protected function _autoload($patterns, $className) { foreach ($patterns as $pattern) { if (!fnmatch($pattern, $className, FNM_NOESCAPE)) { continue; } $this->generateAndLoadClass($className); return true; } return false; }
[ "protected", "function", "_autoload", "(", "$", "patterns", ",", "$", "className", ")", "{", "foreach", "(", "$", "patterns", "as", "$", "pattern", ")", "{", "if", "(", "!", "fnmatch", "(", "$", "pattern", ",", "$", "className", ",", "FNM_NOESCAPE", ")...
Autoload class if matching any of given patterns @param string[] $patterns @param string $className @return bool
[ "Autoload", "class", "if", "matching", "any", "of", "given", "patterns" ]
a355fc9bece8e6f27fbfd09b1631234f7d73a791
https://github.com/jsiefer/class-mocker/blob/a355fc9bece8e6f27fbfd09b1631234f7d73a791/src/ClassMocker.php#L245-L256
train
jsiefer/class-mocker
src/ClassMocker.php
ClassMocker.evalContent
private function evalContent(FileGenerator $classFileGenerator) { $code = $classFileGenerator->generate(); $code = substr($code, 6); // remove <?php eval($code); }
php
private function evalContent(FileGenerator $classFileGenerator) { $code = $classFileGenerator->generate(); $code = substr($code, 6); // remove <?php eval($code); }
[ "private", "function", "evalContent", "(", "FileGenerator", "$", "classFileGenerator", ")", "{", "$", "code", "=", "$", "classFileGenerator", "->", "generate", "(", ")", ";", "$", "code", "=", "substr", "(", "$", "code", ",", "6", ")", ";", "// remove <?ph...
Eval file content @param FileGenerator $classFileGenerator
[ "Eval", "file", "content" ]
a355fc9bece8e6f27fbfd09b1631234f7d73a791
https://github.com/jsiefer/class-mocker/blob/a355fc9bece8e6f27fbfd09b1631234f7d73a791/src/ClassMocker.php#L263-L269
train
jsiefer/class-mocker
src/ClassMocker.php
ClassMocker.findFile
protected function findFile($className) { $genDir = $this->getGenerationDir(); if (!$genDir) { return null; } $path = [$genDir]; $path[] = str_replace('\\', DIRECTORY_SEPARATOR, $className) . '.php'; $path = implode(DIRECTORY_SEPARATOR, $path); $dir = dirname($path); if (!is_dir($dir) && !@mkdir($dir, 0777, true)) { $e = error_get_last(); throw new \RuntimeException( "Failed to create class generation folder: " . $e['message'] ); } return $path; }
php
protected function findFile($className) { $genDir = $this->getGenerationDir(); if (!$genDir) { return null; } $path = [$genDir]; $path[] = str_replace('\\', DIRECTORY_SEPARATOR, $className) . '.php'; $path = implode(DIRECTORY_SEPARATOR, $path); $dir = dirname($path); if (!is_dir($dir) && !@mkdir($dir, 0777, true)) { $e = error_get_last(); throw new \RuntimeException( "Failed to create class generation folder: " . $e['message'] ); } return $path; }
[ "protected", "function", "findFile", "(", "$", "className", ")", "{", "$", "genDir", "=", "$", "this", "->", "getGenerationDir", "(", ")", ";", "if", "(", "!", "$", "genDir", ")", "{", "return", "null", ";", "}", "$", "path", "=", "[", "$", "genDir...
Retrieve file for class name @param string $className @return string @throws \Exception
[ "Retrieve", "file", "for", "class", "name" ]
a355fc9bece8e6f27fbfd09b1631234f7d73a791
https://github.com/jsiefer/class-mocker/blob/a355fc9bece8e6f27fbfd09b1631234f7d73a791/src/ClassMocker.php#L279-L302
train
geniv/nette-filters
src/FilterLatte.php
FilterLatte.addTag
public static function addTag(string $string, string $tag): string { $lastPoint = strrpos($string, '.'); return ($tag ? substr_replace($string, sprintf('.%s.', $tag), $lastPoint, 1) : $string); }
php
public static function addTag(string $string, string $tag): string { $lastPoint = strrpos($string, '.'); return ($tag ? substr_replace($string, sprintf('.%s.', $tag), $lastPoint, 1) : $string); }
[ "public", "static", "function", "addTag", "(", "string", "$", "string", ",", "string", "$", "tag", ")", ":", "string", "{", "$", "lastPoint", "=", "strrpos", "(", "$", "string", ",", "'.'", ")", ";", "return", "(", "$", "tag", "?", "substr_replace", ...
Add tag. @param string $string @param string $tag @return string
[ "Add", "tag", "." ]
0e7838d7b9c9be6c3ecf17f54353830b30eecea7
https://github.com/geniv/nette-filters/blob/0e7838d7b9c9be6c3ecf17f54353830b30eecea7/src/FilterLatte.php#L47-L51
train
geniv/nette-filters
src/FilterLatte.php
FilterLatte.dateDiff
public static function dateDiff(DateTime $from = null, DateTime $to = null, string $format = 'Y-m-d H:i:s'): string { if (!$from) { return ''; } if (!$to) { // if not define to then to date is set today $to = new DateTime(); } return $from->diff($to)->format($format); }
php
public static function dateDiff(DateTime $from = null, DateTime $to = null, string $format = 'Y-m-d H:i:s'): string { if (!$from) { return ''; } if (!$to) { // if not define to then to date is set today $to = new DateTime(); } return $from->diff($to)->format($format); }
[ "public", "static", "function", "dateDiff", "(", "DateTime", "$", "from", "=", "null", ",", "DateTime", "$", "to", "=", "null", ",", "string", "$", "format", "=", "'Y-m-d H:i:s'", ")", ":", "string", "{", "if", "(", "!", "$", "from", ")", "{", "retur...
Date diff. @param DateTime|null $from @param DateTime|null $to @param string $format @return string @throws \Exception
[ "Date", "diff", "." ]
0e7838d7b9c9be6c3ecf17f54353830b30eecea7
https://github.com/geniv/nette-filters/blob/0e7838d7b9c9be6c3ecf17f54353830b30eecea7/src/FilterLatte.php#L75-L84
train
geniv/nette-filters
src/FilterLatte.php
FilterLatte.googleMapsLink
public static function googleMapsLink(string $query): string { $result = $query; if ($query) { $result = 'https://www.google.com/maps/search/?api=1&query=' . $query; } return $result; }
php
public static function googleMapsLink(string $query): string { $result = $query; if ($query) { $result = 'https://www.google.com/maps/search/?api=1&query=' . $query; } return $result; }
[ "public", "static", "function", "googleMapsLink", "(", "string", "$", "query", ")", ":", "string", "{", "$", "result", "=", "$", "query", ";", "if", "(", "$", "query", ")", "{", "$", "result", "=", "'https://www.google.com/maps/search/?api=1&query='", ".", "...
Google maps link. @see https://developers.google.com/maps/documentation/urls/guide @param string $query @return string
[ "Google", "maps", "link", "." ]
0e7838d7b9c9be6c3ecf17f54353830b30eecea7
https://github.com/geniv/nette-filters/blob/0e7838d7b9c9be6c3ecf17f54353830b30eecea7/src/FilterLatte.php#L94-L101
train
geniv/nette-filters
src/FilterLatte.php
FilterLatte.toUrl
public static function toUrl(string $url, string $scheme = 'http://'): string { $http = preg_match('/^http[s]?:\/\//', $url); return (!$http ? $scheme : '') . $url; }
php
public static function toUrl(string $url, string $scheme = 'http://'): string { $http = preg_match('/^http[s]?:\/\//', $url); return (!$http ? $scheme : '') . $url; }
[ "public", "static", "function", "toUrl", "(", "string", "$", "url", ",", "string", "$", "scheme", "=", "'http://'", ")", ":", "string", "{", "$", "http", "=", "preg_match", "(", "'/^http[s]?:\\/\\//'", ",", "$", "url", ")", ";", "return", "(", "!", "$"...
To url. @param string $url @param string $scheme @return string
[ "To", "url", "." ]
0e7838d7b9c9be6c3ecf17f54353830b30eecea7
https://github.com/geniv/nette-filters/blob/0e7838d7b9c9be6c3ecf17f54353830b30eecea7/src/FilterLatte.php#L111-L115
train
geniv/nette-filters
src/FilterLatte.php
FilterLatte.realUrl
public static function realUrl(string $value) { list($scheme, $url) = explode('//', $value); $reverse = explode('/', $url); $arr = []; foreach ($reverse as $item) { $arr[] = $item; if ($item == '..') { array_pop($arr); // remove 2x from array stack array_pop($arr); } } return $scheme . '//' . implode('/', $arr); }
php
public static function realUrl(string $value) { list($scheme, $url) = explode('//', $value); $reverse = explode('/', $url); $arr = []; foreach ($reverse as $item) { $arr[] = $item; if ($item == '..') { array_pop($arr); // remove 2x from array stack array_pop($arr); } } return $scheme . '//' . implode('/', $arr); }
[ "public", "static", "function", "realUrl", "(", "string", "$", "value", ")", "{", "list", "(", "$", "scheme", ",", "$", "url", ")", "=", "explode", "(", "'//'", ",", "$", "value", ")", ";", "$", "reverse", "=", "explode", "(", "'/'", ",", "$", "u...
Real url. @param string $value @return string
[ "Real", "url", "." ]
0e7838d7b9c9be6c3ecf17f54353830b30eecea7
https://github.com/geniv/nette-filters/blob/0e7838d7b9c9be6c3ecf17f54353830b30eecea7/src/FilterLatte.php#L124-L137
train
rollun-com/rollun-permission
src/Permission/src/Authentication/AuthenticationChain.php
AuthenticationChain.authenticate
public function authenticate(ServerRequestInterface $request): ?UserInterface { foreach ($this->authenticationServices as $authenticationService) { $user = $authenticationService->authenticate($request); if ($user !== null) { return $user; } } return null; }
php
public function authenticate(ServerRequestInterface $request): ?UserInterface { foreach ($this->authenticationServices as $authenticationService) { $user = $authenticationService->authenticate($request); if ($user !== null) { return $user; } } return null; }
[ "public", "function", "authenticate", "(", "ServerRequestInterface", "$", "request", ")", ":", "?", "UserInterface", "{", "foreach", "(", "$", "this", "->", "authenticationServices", "as", "$", "authenticationService", ")", "{", "$", "user", "=", "$", "authentic...
Chain available authentication services and try authenticate using it If no one authentication service can authenticate return null Other way return user from first service that can authenticate Last authentication service provide an unauthorized response if no one can authenticate @param ServerRequestInterface $request @return UserInterface
[ "Chain", "available", "authentication", "services", "and", "try", "authenticate", "using", "it", "If", "no", "one", "authentication", "service", "can", "authenticate", "return", "null", "Other", "way", "return", "user", "from", "first", "service", "that", "can", ...
9f58c814337fcfd1e52ecfbf496f95d276d8217e
https://github.com/rollun-com/rollun-permission/blob/9f58c814337fcfd1e52ecfbf496f95d276d8217e/src/Permission/src/Authentication/AuthenticationChain.php#L50-L61
train
AnonymPHP/Anonym-Library
src/Anonym/Application/ServiceProvider.php
ServiceProvider.registerProvider
public function registerProvider($provider){ $providers = (array) $provider; foreach($providers as $provider){ $this->app()['config']->add('general.providers', $provider); } }
php
public function registerProvider($provider){ $providers = (array) $provider; foreach($providers as $provider){ $this->app()['config']->add('general.providers', $provider); } }
[ "public", "function", "registerProvider", "(", "$", "provider", ")", "{", "$", "providers", "=", "(", "array", ")", "$", "provider", ";", "foreach", "(", "$", "providers", "as", "$", "provider", ")", "{", "$", "this", "->", "app", "(", ")", "[", "'co...
You can register your providers with string or array data. @param array|string $provider @return $this
[ "You", "can", "register", "your", "providers", "with", "string", "or", "array", "data", "." ]
c967ad804f84e8fb204593a0959cda2fed5ae075
https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Application/ServiceProvider.php#L108-L114
train
marando/phpSOFA
src/Marando/IAU/iauApcs13.php
iauApcs13.Apcs13
public static function Apcs13($date1, $date2, array $pv, iauASTROM $astrom) { $ehpv = []; $ebpv = []; /* Earth barycentric & heliocentric position/velocity (au, au/d). */ IAU::Epv00($date1, $date2, $ehpv, $ebpv); /* Compute the star-independent astrometry parameters. */ IAU::Apcs($date1, $date2, $pv, $ebpv, $ehpv[0], $astrom); /* Finished. */ }
php
public static function Apcs13($date1, $date2, array $pv, iauASTROM $astrom) { $ehpv = []; $ebpv = []; /* Earth barycentric & heliocentric position/velocity (au, au/d). */ IAU::Epv00($date1, $date2, $ehpv, $ebpv); /* Compute the star-independent astrometry parameters. */ IAU::Apcs($date1, $date2, $pv, $ebpv, $ehpv[0], $astrom); /* Finished. */ }
[ "public", "static", "function", "Apcs13", "(", "$", "date1", ",", "$", "date2", ",", "array", "$", "pv", ",", "iauASTROM", "$", "astrom", ")", "{", "$", "ehpv", "=", "[", "]", ";", "$", "ebpv", "=", "[", "]", ";", "/* Earth barycentric & heliocentric p...
- - - - - - - - - - i a u A p c s 1 3 - - - - - - - - - - For an observer whose geocentric position and velocity are known, prepare star-independent astrometry parameters for transformations between ICRS and GCRS. The Earth ephemeris is from SOFA models. The parameters produced by this function are required in the space motion, parallax, light deflection and aberration parts of the astrometric transformation chain. This function is part of the International Astronomical Union's SOFA (Standards of Fundamental Astronomy) software collection. Status: support function. Given: date1 double TDB as a 2-part... date2 double ...Julian Date (Note 1) pv double[2][3] observer's geocentric pos/vel (Note 3) Returned: astrom iauASTROM* star-independent astrometry parameters: pmt double PM time interval (SSB, Julian years) eb double[3] SSB to observer (vector, au) eh double[3] Sun to observer (unit vector) em double distance from Sun to observer (au) v double[3] barycentric observer velocity (vector, c) bm1 double sqrt(1-|v|^2): reciprocal of Lorenz factor bpn double[3][3] bias-precession-nutation matrix along double unchanged xpl double unchanged ypl double unchanged sphi double unchanged cphi double unchanged diurab double unchanged eral double unchanged refa double unchanged refb double unchanged Notes: 1) The TDB date date1+date2 is a Julian Date, apportioned in any convenient way between the two arguments. For example, JD(TDB)=2450123.7 could be expressed in any of these ways, among others: date1 date2 2450123.7 0.0 (JD method) 2451545.0 -1421.3 (J2000 method) 2400000.5 50123.2 (MJD method) 2450123.5 0.2 (date & time method) The JD method is the most natural and convenient to use in cases where the loss of several decimal digits of resolution is acceptable. The J2000 method is best matched to the way the argument is handled internally and will deliver the optimum resolution. The MJD method and the date & time methods are both good compromises between resolution and convenience. For most applications of this function the choice will not be at all critical. TT can be used instead of TDB without any significant impact on accuracy. 2) All the vectors are with respect to BCRS axes. 3) The observer's position and velocity pv are geocentric but with respect to BCRS axes, and in units of m and m/s. No assumptions are made about proximity to the Earth, and the function can be used for deep space applications as well as Earth orbit and terrestrial. 4) In cases where the caller wishes to supply his own Earth ephemeris, the function iauApcs can be used instead of the present function. 5) This is one of several functions that inserts into the astrom structure star-independent parameters needed for the chain of astrometric transformations ICRS <-> GCRS <-> CIRS <-> observed. The various functions support different classes of observer and portions of the transformation chain: functions observer transformation iauApcg iauApcg13 geocentric ICRS <-> GCRS iauApci iauApci13 terrestrial ICRS <-> CIRS iauApco iauApco13 terrestrial ICRS <-> observed iauApcs iauApcs13 space ICRS <-> GCRS iauAper iauAper13 terrestrial update Earth rotation iauApio iauApio13 terrestrial CIRS <-> observed Those with names ending in "13" use contemporary SOFA models to compute the various ephemerides. The others accept ephemerides supplied by the caller. The transformation from ICRS to GCRS covers space motion, parallax, light deflection, and aberration. From GCRS to CIRS comprises frame bias and precession-nutation. From CIRS to observed takes account of Earth rotation, polar motion, diurnal aberration and parallax (unless subsumed into the ICRS <-> GCRS transformation), and atmospheric refraction. 6) The context structure astrom produced by this function is used by iauAtciq* and iauAticq*. Called: iauEpv00 Earth position and velocity iauApcs astrometry parameters, ICRS-GCRS, space observer This revision: 2013 October 9 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "i", "a", "u", "A", "p", "c", "s", "1", "3", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauApcs13.php#L127-L138
train
setrun/setrun-component-user
src/services/AuthService.php
AuthService.auth
public function auth(LoginForm $form): User { $this->checkFailure(); $user = $this->user->findByUsernameOrEmail($form->username); if (!$user || !$user->validatePassword($form->password)) { $this->setFailure(); throw new \DomainException($this->i18n->t('setrun/user', 'Wrong Username or Password')); } if ($user && $user->status == User::STATUS_BLOCKED) { throw new \DomainException($this->i18n->t('setrun/user', 'Account temporarily blocked')); } if ($user && $user->status == User::STATUS_WAIT) { throw new \DomainException($this->i18n->t('setrun/user', 'Account not confirmed')); } $this->removeFailure(); return $user; }
php
public function auth(LoginForm $form): User { $this->checkFailure(); $user = $this->user->findByUsernameOrEmail($form->username); if (!$user || !$user->validatePassword($form->password)) { $this->setFailure(); throw new \DomainException($this->i18n->t('setrun/user', 'Wrong Username or Password')); } if ($user && $user->status == User::STATUS_BLOCKED) { throw new \DomainException($this->i18n->t('setrun/user', 'Account temporarily blocked')); } if ($user && $user->status == User::STATUS_WAIT) { throw new \DomainException($this->i18n->t('setrun/user', 'Account not confirmed')); } $this->removeFailure(); return $user; }
[ "public", "function", "auth", "(", "LoginForm", "$", "form", ")", ":", "User", "{", "$", "this", "->", "checkFailure", "(", ")", ";", "$", "user", "=", "$", "this", "->", "user", "->", "findByUsernameOrEmail", "(", "$", "form", "->", "username", ")", ...
User auth. @param LoginForm $form @return User
[ "User", "auth", "." ]
6aca4c62f099918032b66da1f94d7565694a0735
https://github.com/setrun/setrun-component-user/blob/6aca4c62f099918032b66da1f94d7565694a0735/src/services/AuthService.php#L57-L73
train
setrun/setrun-component-user
src/services/AuthService.php
AuthService.checkFailure
private function checkFailure() : void { $failure = (int) $this->session->get('failure', 0); $time = (int) $this->session->get('failure_time', time()); if ($failure >= static::FAILURE) { if ($time >= time()) { throw new \DomainException($this->i18n->t( 'setrun/user', 'Form is blocked for {min} minutes', ['min' => static::FAILURE_TIME / 60]) ); } $this->removeFailure(); } }
php
private function checkFailure() : void { $failure = (int) $this->session->get('failure', 0); $time = (int) $this->session->get('failure_time', time()); if ($failure >= static::FAILURE) { if ($time >= time()) { throw new \DomainException($this->i18n->t( 'setrun/user', 'Form is blocked for {min} minutes', ['min' => static::FAILURE_TIME / 60]) ); } $this->removeFailure(); } }
[ "private", "function", "checkFailure", "(", ")", ":", "void", "{", "$", "failure", "=", "(", "int", ")", "$", "this", "->", "session", "->", "get", "(", "'failure'", ",", "0", ")", ";", "$", "time", "=", "(", "int", ")", "$", "this", "->", "sessi...
Check for failure of access. @return void
[ "Check", "for", "failure", "of", "access", "." ]
6aca4c62f099918032b66da1f94d7565694a0735
https://github.com/setrun/setrun-component-user/blob/6aca4c62f099918032b66da1f94d7565694a0735/src/services/AuthService.php#L79-L93
train
setrun/setrun-component-user
src/services/AuthService.php
AuthService.setFailure
private function setFailure() : void { $this->session->set('failure', $this->session->get('failure') + 1); $this->session->set('failure_time', time() + (int) static::FAILURE_TIME); }
php
private function setFailure() : void { $this->session->set('failure', $this->session->get('failure') + 1); $this->session->set('failure_time', time() + (int) static::FAILURE_TIME); }
[ "private", "function", "setFailure", "(", ")", ":", "void", "{", "$", "this", "->", "session", "->", "set", "(", "'failure'", ",", "$", "this", "->", "session", "->", "get", "(", "'failure'", ")", "+", "1", ")", ";", "$", "this", "->", "session", "...
Set a failure. @return void
[ "Set", "a", "failure", "." ]
6aca4c62f099918032b66da1f94d7565694a0735
https://github.com/setrun/setrun-component-user/blob/6aca4c62f099918032b66da1f94d7565694a0735/src/services/AuthService.php#L99-L103
train
okaufmann/google-movies-client
src/GoogleMoviesClient/HttpClient/Adapter/AbstractAdapter.php
AbstractAdapter.createApiException
protected function createApiException(Request $request, Response $response) { //$errors = json_decode((string) $response->getBody()); return new HttpRequestException( $response->getCode(), $response->getBody(), $request, $response ); }
php
protected function createApiException(Request $request, Response $response) { //$errors = json_decode((string) $response->getBody()); return new HttpRequestException( $response->getCode(), $response->getBody(), $request, $response ); }
[ "protected", "function", "createApiException", "(", "Request", "$", "request", ",", "Response", "$", "response", ")", "{", "//$errors = json_decode((string) $response->getBody());", "return", "new", "HttpRequestException", "(", "$", "response", "->", "getCode", "(", ")"...
Create the unified exception to throw. @param Request $request @param Response $response @return HttpRequestException
[ "Create", "the", "unified", "exception", "to", "throw", "." ]
70ad4d3c640016cf24a0fd45ed8509029a6c02c6
https://github.com/okaufmann/google-movies-client/blob/70ad4d3c640016cf24a0fd45ed8509029a6c02c6/src/GoogleMoviesClient/HttpClient/Adapter/AbstractAdapter.php#L33-L43
train
OpenResourceManager/client-php
src/Client/Account.php
Account.detachFromDuty
public function detachFromDuty($id = null, $identifier = null, $username = null, $duty_id = null, $code = null) { $fields = []; if (!is_null($id)) $fields['id'] = $id; if (!is_null($identifier)) $fields['identifier'] = $identifier; if (!is_null($username)) $fields['username'] = $username; if (!is_null($duty_id)) $fields['duty_id'] = $duty_id; if (!is_null($code)) $fields['code'] = $code; return $this->_del($fields, 'duty'); }
php
public function detachFromDuty($id = null, $identifier = null, $username = null, $duty_id = null, $code = null) { $fields = []; if (!is_null($id)) $fields['id'] = $id; if (!is_null($identifier)) $fields['identifier'] = $identifier; if (!is_null($username)) $fields['username'] = $username; if (!is_null($duty_id)) $fields['duty_id'] = $duty_id; if (!is_null($code)) $fields['code'] = $code; return $this->_del($fields, 'duty'); }
[ "public", "function", "detachFromDuty", "(", "$", "id", "=", "null", ",", "$", "identifier", "=", "null", ",", "$", "username", "=", "null", ",", "$", "duty_id", "=", "null", ",", "$", "code", "=", "null", ")", "{", "$", "fields", "=", "[", "]", ...
Detach Account From Duty Detach this account from a duty. Using either the account ID, identifier, or username with either the duty ID or code. @param int $id @param string $identifier @param string $username @param int $duty_id @param string $code @return \Unirest\Response
[ "Detach", "Account", "From", "Duty" ]
fa468e3425d32f97294fefed77a7f096f3f8cc86
https://github.com/OpenResourceManager/client-php/blob/fa468e3425d32f97294fefed77a7f096f3f8cc86/src/Client/Account.php#L307-L318
train
OpenResourceManager/client-php
src/Client/Account.php
Account.attachToDuty
public function attachToDuty($id = null, $identifier = null, $username = null, $duty_id = null, $code = null) { $fields = []; if (!is_null($id)) $fields['id'] = $id; if (!is_null($identifier)) $fields['identifier'] = $identifier; if (!is_null($username)) $fields['username'] = $username; if (!is_null($duty_id)) $fields['duty_id'] = $duty_id; if (!is_null($code)) $fields['code'] = $code; return $this->_post($fields, 'duty'); }
php
public function attachToDuty($id = null, $identifier = null, $username = null, $duty_id = null, $code = null) { $fields = []; if (!is_null($id)) $fields['id'] = $id; if (!is_null($identifier)) $fields['identifier'] = $identifier; if (!is_null($username)) $fields['username'] = $username; if (!is_null($duty_id)) $fields['duty_id'] = $duty_id; if (!is_null($code)) $fields['code'] = $code; return $this->_post($fields, 'duty'); }
[ "public", "function", "attachToDuty", "(", "$", "id", "=", "null", ",", "$", "identifier", "=", "null", ",", "$", "username", "=", "null", ",", "$", "duty_id", "=", "null", ",", "$", "code", "=", "null", ")", "{", "$", "fields", "=", "[", "]", ";...
Attach Account To Duty Attach this account to a duty. Using either the account ID, identifier, or username with either the duty ID or code. @param int $id @param string $identifier @param string $username @param int $duty_id @param string $code @return \Unirest\Response
[ "Attach", "Account", "To", "Duty" ]
fa468e3425d32f97294fefed77a7f096f3f8cc86
https://github.com/OpenResourceManager/client-php/blob/fa468e3425d32f97294fefed77a7f096f3f8cc86/src/Client/Account.php#L332-L343
train