id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
7,100
phlexible/phlexible
src/Phlexible/Bundle/CmsBundle/Twig/Extension/MiscExtension.php
MiscExtension.age
public function age($date1, $date2 = null) { $formatter = new AgeFormatter(); return $formatter->formatDate($date1, $date2); }
php
public function age($date1, $date2 = null) { $formatter = new AgeFormatter(); return $formatter->formatDate($date1, $date2); }
[ "public", "function", "age", "(", "$", "date1", ",", "$", "date2", "=", "null", ")", "{", "$", "formatter", "=", "new", "AgeFormatter", "(", ")", ";", "return", "$", "formatter", "->", "formatDate", "(", "$", "date1", ",", "$", "date2", ")", ";", "}" ]
Return age string for given date. @param string $date1 @param string|null $date2 @return string
[ "Return", "age", "string", "for", "given", "date", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/CmsBundle/Twig/Extension/MiscExtension.php#L90-L95
7,101
wasabi-cms/cms
src/Controller/MenusController.php
MenusController.index
public function index() { $menus = $this->Filter->filter($this->Menus->find('all'))->hydrate(false); $this->set('menus', $menus); }
php
public function index() { $menus = $this->Filter->filter($this->Menus->find('all'))->hydrate(false); $this->set('menus', $menus); }
[ "public", "function", "index", "(", ")", "{", "$", "menus", "=", "$", "this", "->", "Filter", "->", "filter", "(", "$", "this", "->", "Menus", "->", "find", "(", "'all'", ")", ")", "->", "hydrate", "(", "false", ")", ";", "$", "this", "->", "set", "(", "'menus'", ",", "$", "menus", ")", ";", "}" ]
index action GET
[ "index", "action", "GET" ]
2787b6422ea1d719cf49951b3253fd0ac31d22ca
https://github.com/wasabi-cms/cms/blob/2787b6422ea1d719cf49951b3253fd0ac31d22ca/src/Controller/MenusController.php#L73-L77
7,102
wasabi-cms/cms
src/Controller/MenusController.php
MenusController.deleteItem
public function deleteItem($id) { $this->request->allowMethod('post'); $menuItem = $this->MenuItems->get($id); if ($this->MenuItems->delete($menuItem)) { $this->Flash->success(__d('wasabi_core', 'The menu item <strong>{0}</strong> has been deleted.', $menuItem->get('name'))); } else { $this->Flash->error($this->dbErrorMessage); } $this->redirect(['action' => 'edit', $menuItem->get('menu_id')]); return; }
php
public function deleteItem($id) { $this->request->allowMethod('post'); $menuItem = $this->MenuItems->get($id); if ($this->MenuItems->delete($menuItem)) { $this->Flash->success(__d('wasabi_core', 'The menu item <strong>{0}</strong> has been deleted.', $menuItem->get('name'))); } else { $this->Flash->error($this->dbErrorMessage); } $this->redirect(['action' => 'edit', $menuItem->get('menu_id')]); return; }
[ "public", "function", "deleteItem", "(", "$", "id", ")", "{", "$", "this", "->", "request", "->", "allowMethod", "(", "'post'", ")", ";", "$", "menuItem", "=", "$", "this", "->", "MenuItems", "->", "get", "(", "$", "id", ")", ";", "if", "(", "$", "this", "->", "MenuItems", "->", "delete", "(", "$", "menuItem", ")", ")", "{", "$", "this", "->", "Flash", "->", "success", "(", "__d", "(", "'wasabi_core'", ",", "'The menu item <strong>{0}</strong> has been deleted.'", ",", "$", "menuItem", "->", "get", "(", "'name'", ")", ")", ")", ";", "}", "else", "{", "$", "this", "->", "Flash", "->", "error", "(", "$", "this", "->", "dbErrorMessage", ")", ";", "}", "$", "this", "->", "redirect", "(", "[", "'action'", "=>", "'edit'", ",", "$", "menuItem", "->", "get", "(", "'menu_id'", ")", "]", ")", ";", "return", ";", "}" ]
Delete a menu item. POST @param string $id
[ "Delete", "a", "menu", "item", ".", "POST" ]
2787b6422ea1d719cf49951b3253fd0ac31d22ca
https://github.com/wasabi-cms/cms/blob/2787b6422ea1d719cf49951b3253fd0ac31d22ca/src/Controller/MenusController.php#L230-L243
7,103
wasabi-cms/cms
src/Controller/MenusController.php
MenusController.reorderItems
public function reorderItems() { if (!$this->request->isAll(['ajax', 'post'])) { throw new MethodNotAllowedException(); } if (empty($this->request->data)) { throw new BadRequestException(); } $this->request->data = Hash::map($this->request->data, '{n}', function($item) { if ($item['parent_id'] === 'null') { $item['parent_id'] = null; } return $item; }); // save the new language positions $menuItems = $this->MenuItems->patchEntities( $this->MenuItems->find('threaded'), $this->request->data ); $this->MenuItems->connection()->begin(); foreach ($menuItems as $menuItem) { $this->MenuItems->behaviors()->unload('Tree'); if (!$this->MenuItems->save($menuItem)) { $this->MenuItems->connection()->rollback(); break; } } if ($this->MenuItems->connection()->inTransaction()) { $this->MenuItems->connection()->commit(); $status = 'success'; $flashMessage = __d('wasabi_core', 'The menu item positions have been updated.'); } else { $status = 'error'; $flashMessage = $this->dbErrorMessage; } $this->set([ 'status' => $status, 'flashMessage' => $flashMessage, '_serialize' => ['status', 'flashMessage'] ]); }
php
public function reorderItems() { if (!$this->request->isAll(['ajax', 'post'])) { throw new MethodNotAllowedException(); } if (empty($this->request->data)) { throw new BadRequestException(); } $this->request->data = Hash::map($this->request->data, '{n}', function($item) { if ($item['parent_id'] === 'null') { $item['parent_id'] = null; } return $item; }); // save the new language positions $menuItems = $this->MenuItems->patchEntities( $this->MenuItems->find('threaded'), $this->request->data ); $this->MenuItems->connection()->begin(); foreach ($menuItems as $menuItem) { $this->MenuItems->behaviors()->unload('Tree'); if (!$this->MenuItems->save($menuItem)) { $this->MenuItems->connection()->rollback(); break; } } if ($this->MenuItems->connection()->inTransaction()) { $this->MenuItems->connection()->commit(); $status = 'success'; $flashMessage = __d('wasabi_core', 'The menu item positions have been updated.'); } else { $status = 'error'; $flashMessage = $this->dbErrorMessage; } $this->set([ 'status' => $status, 'flashMessage' => $flashMessage, '_serialize' => ['status', 'flashMessage'] ]); }
[ "public", "function", "reorderItems", "(", ")", "{", "if", "(", "!", "$", "this", "->", "request", "->", "isAll", "(", "[", "'ajax'", ",", "'post'", "]", ")", ")", "{", "throw", "new", "MethodNotAllowedException", "(", ")", ";", "}", "if", "(", "empty", "(", "$", "this", "->", "request", "->", "data", ")", ")", "{", "throw", "new", "BadRequestException", "(", ")", ";", "}", "$", "this", "->", "request", "->", "data", "=", "Hash", "::", "map", "(", "$", "this", "->", "request", "->", "data", ",", "'{n}'", ",", "function", "(", "$", "item", ")", "{", "if", "(", "$", "item", "[", "'parent_id'", "]", "===", "'null'", ")", "{", "$", "item", "[", "'parent_id'", "]", "=", "null", ";", "}", "return", "$", "item", ";", "}", ")", ";", "// save the new language positions", "$", "menuItems", "=", "$", "this", "->", "MenuItems", "->", "patchEntities", "(", "$", "this", "->", "MenuItems", "->", "find", "(", "'threaded'", ")", ",", "$", "this", "->", "request", "->", "data", ")", ";", "$", "this", "->", "MenuItems", "->", "connection", "(", ")", "->", "begin", "(", ")", ";", "foreach", "(", "$", "menuItems", "as", "$", "menuItem", ")", "{", "$", "this", "->", "MenuItems", "->", "behaviors", "(", ")", "->", "unload", "(", "'Tree'", ")", ";", "if", "(", "!", "$", "this", "->", "MenuItems", "->", "save", "(", "$", "menuItem", ")", ")", "{", "$", "this", "->", "MenuItems", "->", "connection", "(", ")", "->", "rollback", "(", ")", ";", "break", ";", "}", "}", "if", "(", "$", "this", "->", "MenuItems", "->", "connection", "(", ")", "->", "inTransaction", "(", ")", ")", "{", "$", "this", "->", "MenuItems", "->", "connection", "(", ")", "->", "commit", "(", ")", ";", "$", "status", "=", "'success'", ";", "$", "flashMessage", "=", "__d", "(", "'wasabi_core'", ",", "'The menu item positions have been updated.'", ")", ";", "}", "else", "{", "$", "status", "=", "'error'", ";", "$", "flashMessage", "=", "$", "this", "->", "dbErrorMessage", ";", "}", "$", "this", "->", "set", "(", "[", "'status'", "=>", "$", "status", ",", "'flashMessage'", "=>", "$", "flashMessage", ",", "'_serialize'", "=>", "[", "'status'", ",", "'flashMessage'", "]", "]", ")", ";", "}" ]
reorderItems action AJAX POST
[ "reorderItems", "action", "AJAX", "POST" ]
2787b6422ea1d719cf49951b3253fd0ac31d22ca
https://github.com/wasabi-cms/cms/blob/2787b6422ea1d719cf49951b3253fd0ac31d22ca/src/Controller/MenusController.php#L249-L293
7,104
thecodingmachine/utils.i18n.fine.file-translator
src/FileTranslator.php
FileTranslator.getPath
private function getPath() { if(strpos($this->i18nMessagePath, '/') === 0 || strpos($this->i18nMessagePath, ':/') === 1) { return $this->i18nMessagePath; } return ROOT_PATH.$this->i18nMessagePath; }
php
private function getPath() { if(strpos($this->i18nMessagePath, '/') === 0 || strpos($this->i18nMessagePath, ':/') === 1) { return $this->i18nMessagePath; } return ROOT_PATH.$this->i18nMessagePath; }
[ "private", "function", "getPath", "(", ")", "{", "if", "(", "strpos", "(", "$", "this", "->", "i18nMessagePath", ",", "'/'", ")", "===", "0", "||", "strpos", "(", "$", "this", "->", "i18nMessagePath", ",", "':/'", ")", "===", "1", ")", "{", "return", "$", "this", "->", "i18nMessagePath", ";", "}", "return", "ROOT_PATH", ".", "$", "this", "->", "i18nMessagePath", ";", "}" ]
This function return the real path set in parameter. @return string
[ "This", "function", "return", "the", "real", "path", "set", "in", "parameter", "." ]
67b180fed62562b36d28d6d61707fde4f62abf9a
https://github.com/thecodingmachine/utils.i18n.fine.file-translator/blob/67b180fed62562b36d28d6d61707fde4f62abf9a/src/FileTranslator.php#L81-L86
7,105
thecodingmachine/utils.i18n.fine.file-translator
src/FileTranslator.php
FileTranslator.getMessageFile
private function getMessageFile($language) { if(!isset($this->messageFile[$language])) { $this->messageFile[$language] = new MessageFileLanguage($this->getPath(), $language); } return $this->messageFile[$language]; }
php
private function getMessageFile($language) { if(!isset($this->messageFile[$language])) { $this->messageFile[$language] = new MessageFileLanguage($this->getPath(), $language); } return $this->messageFile[$language]; }
[ "private", "function", "getMessageFile", "(", "$", "language", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "messageFile", "[", "$", "language", "]", ")", ")", "{", "$", "this", "->", "messageFile", "[", "$", "language", "]", "=", "new", "MessageFileLanguage", "(", "$", "this", "->", "getPath", "(", ")", ",", "$", "language", ")", ";", "}", "return", "$", "this", "->", "messageFile", "[", "$", "language", "]", ";", "}" ]
Return the instance of the MessageFileLanguage Each MessageFileLanguage is link to one language @param string $language @return MessageFileLanguage
[ "Return", "the", "instance", "of", "the", "MessageFileLanguage", "Each", "MessageFileLanguage", "is", "link", "to", "one", "language" ]
67b180fed62562b36d28d6d61707fde4f62abf9a
https://github.com/thecodingmachine/utils.i18n.fine.file-translator/blob/67b180fed62562b36d28d6d61707fde4f62abf9a/src/FileTranslator.php#L95-L100
7,106
thecodingmachine/utils.i18n.fine.file-translator
src/FileTranslator.php
FileTranslator.getTranslationsForLanguage
public function getTranslationsForLanguage($language) { if (!isset($this->messages[$language])) { $messageLanguage = $this->getMessageFile($language); $this->messages[$language] = $messageLanguage->getAllMessages(); } return $this->messages[$language]; }
php
public function getTranslationsForLanguage($language) { if (!isset($this->messages[$language])) { $messageLanguage = $this->getMessageFile($language); $this->messages[$language] = $messageLanguage->getAllMessages(); } return $this->messages[$language]; }
[ "public", "function", "getTranslationsForLanguage", "(", "$", "language", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "messages", "[", "$", "language", "]", ")", ")", "{", "$", "messageLanguage", "=", "$", "this", "->", "getMessageFile", "(", "$", "language", ")", ";", "$", "this", "->", "messages", "[", "$", "language", "]", "=", "$", "messageLanguage", "->", "getAllMessages", "(", ")", ";", "}", "return", "$", "this", "->", "messages", "[", "$", "language", "]", ";", "}" ]
Return a list of all message for a language. @param string $language Language @return array<string, string> List with key value of translation
[ "Return", "a", "list", "of", "all", "message", "for", "a", "language", "." ]
67b180fed62562b36d28d6d61707fde4f62abf9a
https://github.com/thecodingmachine/utils.i18n.fine.file-translator/blob/67b180fed62562b36d28d6d61707fde4f62abf9a/src/FileTranslator.php#L175-L181
7,107
thecodingmachine/utils.i18n.fine.file-translator
src/FileTranslator.php
FileTranslator.getTranslationsForKey
public function getTranslationsForKey($key) { $this->getAllTranslationByLanguage(); $translations = []; foreach ($this->messages as $language => $messages) { foreach ($messages as $messageKey => $message) { if($key == $messageKey) { $translations[$language] = $message; } } } return $translations; }
php
public function getTranslationsForKey($key) { $this->getAllTranslationByLanguage(); $translations = []; foreach ($this->messages as $language => $messages) { foreach ($messages as $messageKey => $message) { if($key == $messageKey) { $translations[$language] = $message; } } } return $translations; }
[ "public", "function", "getTranslationsForKey", "(", "$", "key", ")", "{", "$", "this", "->", "getAllTranslationByLanguage", "(", ")", ";", "$", "translations", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "messages", "as", "$", "language", "=>", "$", "messages", ")", "{", "foreach", "(", "$", "messages", "as", "$", "messageKey", "=>", "$", "message", ")", "{", "if", "(", "$", "key", "==", "$", "messageKey", ")", "{", "$", "translations", "[", "$", "language", "]", "=", "$", "message", ";", "}", "}", "}", "return", "$", "translations", ";", "}" ]
Return a list of all message for a key, by language. @param string $key Key of translation @return array<string, string> List with key value of translation
[ "Return", "a", "list", "of", "all", "message", "for", "a", "key", "by", "language", "." ]
67b180fed62562b36d28d6d61707fde4f62abf9a
https://github.com/thecodingmachine/utils.i18n.fine.file-translator/blob/67b180fed62562b36d28d6d61707fde4f62abf9a/src/FileTranslator.php#L189-L200
7,108
thecodingmachine/utils.i18n.fine.file-translator
src/FileTranslator.php
FileTranslator.deleteTranslation
public function deleteTranslation($key, $language = null) { if($language === null) { $languages = $this->getLanguageList(); } else { $languages = array($language); } foreach ($languages as $language) { $messageFile = $this->getMessageFile($language); $messageFile->deleteMessage($key); $messageFile->save(); unset($this->messages[$language][$key]); } }
php
public function deleteTranslation($key, $language = null) { if($language === null) { $languages = $this->getLanguageList(); } else { $languages = array($language); } foreach ($languages as $language) { $messageFile = $this->getMessageFile($language); $messageFile->deleteMessage($key); $messageFile->save(); unset($this->messages[$language][$key]); } }
[ "public", "function", "deleteTranslation", "(", "$", "key", ",", "$", "language", "=", "null", ")", "{", "if", "(", "$", "language", "===", "null", ")", "{", "$", "languages", "=", "$", "this", "->", "getLanguageList", "(", ")", ";", "}", "else", "{", "$", "languages", "=", "array", "(", "$", "language", ")", ";", "}", "foreach", "(", "$", "languages", "as", "$", "language", ")", "{", "$", "messageFile", "=", "$", "this", "->", "getMessageFile", "(", "$", "language", ")", ";", "$", "messageFile", "->", "deleteMessage", "(", "$", "key", ")", ";", "$", "messageFile", "->", "save", "(", ")", ";", "unset", "(", "$", "this", "->", "messages", "[", "$", "language", "]", "[", "$", "key", "]", ")", ";", "}", "}" ]
Delete a translation for a language. If the language is not set or null, this function deletes the translation for all language. @param string $key Key to remove @param string|null $language Language to remove key or null for all
[ "Delete", "a", "translation", "for", "a", "language", ".", "If", "the", "language", "is", "not", "set", "or", "null", "this", "function", "deletes", "the", "translation", "for", "all", "language", "." ]
67b180fed62562b36d28d6d61707fde4f62abf9a
https://github.com/thecodingmachine/utils.i18n.fine.file-translator/blob/67b180fed62562b36d28d6d61707fde4f62abf9a/src/FileTranslator.php#L208-L222
7,109
thecodingmachine/utils.i18n.fine.file-translator
src/FileTranslator.php
FileTranslator.setTranslation
public function setTranslation($key, $value, $language) { $messageFile = $this->getMessageFile($language); $messageFile->setMessage($key, $value); $messageFile->save(); $this->messages[$language][$key] = $value; }
php
public function setTranslation($key, $value, $language) { $messageFile = $this->getMessageFile($language); $messageFile->setMessage($key, $value); $messageFile->save(); $this->messages[$language][$key] = $value; }
[ "public", "function", "setTranslation", "(", "$", "key", ",", "$", "value", ",", "$", "language", ")", "{", "$", "messageFile", "=", "$", "this", "->", "getMessageFile", "(", "$", "language", ")", ";", "$", "messageFile", "->", "setMessage", "(", "$", "key", ",", "$", "value", ")", ";", "$", "messageFile", "->", "save", "(", ")", ";", "$", "this", "->", "messages", "[", "$", "language", "]", "[", "$", "key", "]", "=", "$", "value", ";", "}" ]
Add or change a translation @param string $key Key of translation @param string $value Message of translation @param string $language Language to add translation
[ "Add", "or", "change", "a", "translation" ]
67b180fed62562b36d28d6d61707fde4f62abf9a
https://github.com/thecodingmachine/utils.i18n.fine.file-translator/blob/67b180fed62562b36d28d6d61707fde4f62abf9a/src/FileTranslator.php#L231-L237
7,110
thecodingmachine/utils.i18n.fine.file-translator
src/FileTranslator.php
FileTranslator.getLanguageList
public function getLanguageList() { $files = glob($this->getPath().'messages_*.php'); $startAt = strlen('messages_'); $languages = array(); foreach ($files as $file) { $base = basename($file); $languages[] = substr($base, $startAt, strrpos($base, '.php') - $startAt); } return $languages; }
php
public function getLanguageList() { $files = glob($this->getPath().'messages_*.php'); $startAt = strlen('messages_'); $languages = array(); foreach ($files as $file) { $base = basename($file); $languages[] = substr($base, $startAt, strrpos($base, '.php') - $startAt); } return $languages; }
[ "public", "function", "getLanguageList", "(", ")", "{", "$", "files", "=", "glob", "(", "$", "this", "->", "getPath", "(", ")", ".", "'messages_*.php'", ")", ";", "$", "startAt", "=", "strlen", "(", "'messages_'", ")", ";", "$", "languages", "=", "array", "(", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "base", "=", "basename", "(", "$", "file", ")", ";", "$", "languages", "[", "]", "=", "substr", "(", "$", "base", ",", "$", "startAt", ",", "strrpos", "(", "$", "base", ",", "'.php'", ")", "-", "$", "startAt", ")", ";", "}", "return", "$", "languages", ";", "}" ]
Liste of all language supported @return array<string>
[ "Liste", "of", "all", "language", "supported" ]
67b180fed62562b36d28d6d61707fde4f62abf9a
https://github.com/thecodingmachine/utils.i18n.fine.file-translator/blob/67b180fed62562b36d28d6d61707fde4f62abf9a/src/FileTranslator.php#L272-L282
7,111
budkit/budkit-framework
src/Budkit/Helper/Time.php
Time.difference
public static function difference($time, $now = NULL, $opt = array()) { //calculates the difference between two times //could be a string, or language //default now is NULL //Solve the 4 decades issue if (date('Y-m-d H:i:s', $time) == "0000-00-00 00:00:00" || empty($time)) { return t('Never'); } $defOptions = array( 'to' => $now, 'parts' => 1, 'precision' => 'sec', 'distance' => true, 'separator' => ', ' ); $opt = array_merge($defOptions, $opt); //If now is empty then set now is to time now; if (!$opt['to']) $opt['to'] = time(); $str = ''; $diff = ($opt['to'] > $time) ? $opt['to'] - $time : $time - $opt['to']; $periods = array( 'decade' => 315569260, 'year' => 31556926, 'month' => 2629744, 'week' => 604800, 'day' => 86400, 'hour' => 3600, 'min' => 60, 'sec' => 1); if ($opt['precision'] != 'sec') { $diff = round(($diff / $periods[$opt['precision']])) * $periods[$opt['precision']]; } (0 == $diff) && ($str = 'less than 1 ' . $opt['precision']); foreach ($periods as $label => $value) { (($x = floor($diff / $value)) && $opt['parts']--) && $str .= ($str ? $opt['separator'] : '') . ($x . ' ' . $label . ($x > 1 ? 's' : '')); if ($opt['parts'] == 0 || $label == $opt['precision']) { break; } $diff -= $x * $value; } $opt['distance'] && $str .= ($str && $opt['to'] > $time) ? ' ago' : ' ago'; //($str && $opt['to'] > $time) ? ' ago' : ' away'; return $str; }
php
public static function difference($time, $now = NULL, $opt = array()) { //calculates the difference between two times //could be a string, or language //default now is NULL //Solve the 4 decades issue if (date('Y-m-d H:i:s', $time) == "0000-00-00 00:00:00" || empty($time)) { return t('Never'); } $defOptions = array( 'to' => $now, 'parts' => 1, 'precision' => 'sec', 'distance' => true, 'separator' => ', ' ); $opt = array_merge($defOptions, $opt); //If now is empty then set now is to time now; if (!$opt['to']) $opt['to'] = time(); $str = ''; $diff = ($opt['to'] > $time) ? $opt['to'] - $time : $time - $opt['to']; $periods = array( 'decade' => 315569260, 'year' => 31556926, 'month' => 2629744, 'week' => 604800, 'day' => 86400, 'hour' => 3600, 'min' => 60, 'sec' => 1); if ($opt['precision'] != 'sec') { $diff = round(($diff / $periods[$opt['precision']])) * $periods[$opt['precision']]; } (0 == $diff) && ($str = 'less than 1 ' . $opt['precision']); foreach ($periods as $label => $value) { (($x = floor($diff / $value)) && $opt['parts']--) && $str .= ($str ? $opt['separator'] : '') . ($x . ' ' . $label . ($x > 1 ? 's' : '')); if ($opt['parts'] == 0 || $label == $opt['precision']) { break; } $diff -= $x * $value; } $opt['distance'] && $str .= ($str && $opt['to'] > $time) ? ' ago' : ' ago'; //($str && $opt['to'] > $time) ? ' ago' : ' away'; return $str; }
[ "public", "static", "function", "difference", "(", "$", "time", ",", "$", "now", "=", "NULL", ",", "$", "opt", "=", "array", "(", ")", ")", "{", "//calculates the difference between two times", "//could be a string, or language", "//default now is NULL", "//Solve the 4 decades issue", "if", "(", "date", "(", "'Y-m-d H:i:s'", ",", "$", "time", ")", "==", "\"0000-00-00 00:00:00\"", "||", "empty", "(", "$", "time", ")", ")", "{", "return", "t", "(", "'Never'", ")", ";", "}", "$", "defOptions", "=", "array", "(", "'to'", "=>", "$", "now", ",", "'parts'", "=>", "1", ",", "'precision'", "=>", "'sec'", ",", "'distance'", "=>", "true", ",", "'separator'", "=>", "', '", ")", ";", "$", "opt", "=", "array_merge", "(", "$", "defOptions", ",", "$", "opt", ")", ";", "//If now is empty then set now is to time now;", "if", "(", "!", "$", "opt", "[", "'to'", "]", ")", "$", "opt", "[", "'to'", "]", "=", "time", "(", ")", ";", "$", "str", "=", "''", ";", "$", "diff", "=", "(", "$", "opt", "[", "'to'", "]", ">", "$", "time", ")", "?", "$", "opt", "[", "'to'", "]", "-", "$", "time", ":", "$", "time", "-", "$", "opt", "[", "'to'", "]", ";", "$", "periods", "=", "array", "(", "'decade'", "=>", "315569260", ",", "'year'", "=>", "31556926", ",", "'month'", "=>", "2629744", ",", "'week'", "=>", "604800", ",", "'day'", "=>", "86400", ",", "'hour'", "=>", "3600", ",", "'min'", "=>", "60", ",", "'sec'", "=>", "1", ")", ";", "if", "(", "$", "opt", "[", "'precision'", "]", "!=", "'sec'", ")", "{", "$", "diff", "=", "round", "(", "(", "$", "diff", "/", "$", "periods", "[", "$", "opt", "[", "'precision'", "]", "]", ")", ")", "*", "$", "periods", "[", "$", "opt", "[", "'precision'", "]", "]", ";", "}", "(", "0", "==", "$", "diff", ")", "&&", "(", "$", "str", "=", "'less than 1 '", ".", "$", "opt", "[", "'precision'", "]", ")", ";", "foreach", "(", "$", "periods", "as", "$", "label", "=>", "$", "value", ")", "{", "(", "(", "$", "x", "=", "floor", "(", "$", "diff", "/", "$", "value", ")", ")", "&&", "$", "opt", "[", "'parts'", "]", "--", ")", "&&", "$", "str", ".=", "(", "$", "str", "?", "$", "opt", "[", "'separator'", "]", ":", "''", ")", ".", "(", "$", "x", ".", "' '", ".", "$", "label", ".", "(", "$", "x", ">", "1", "?", "'s'", ":", "''", ")", ")", ";", "if", "(", "$", "opt", "[", "'parts'", "]", "==", "0", "||", "$", "label", "==", "$", "opt", "[", "'precision'", "]", ")", "{", "break", ";", "}", "$", "diff", "-=", "$", "x", "*", "$", "value", ";", "}", "$", "opt", "[", "'distance'", "]", "&&", "$", "str", ".=", "(", "$", "str", "&&", "$", "opt", "[", "'to'", "]", ">", "$", "time", ")", "?", "' ago'", ":", "' ago'", ";", "//($str && $opt['to'] > $time) ? ' ago' : ' away';", "return", "$", "str", ";", "}" ]
Get time difference between 2 times @param string $time @param string $now @param array $options @return string
[ "Get", "time", "difference", "between", "2", "times" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Helper/Time.php#L61-L111
7,112
novuso/common
src/Domain/Value/Identifier/Url.php
Url.normalizeQuery
protected static function normalizeQuery(?string $query): ?string { if (null === $query) { return null; } if ('' === $query) { return ''; } $parts = []; $order = []; // sort query params by key and remove missing keys foreach (explode('&', $query) as $param) { if ('' === $param || '=' === $param[0]) { continue; } $parts[] = $param; $kvp = explode('=', $param, 2); $order[] = $kvp[0]; } array_multisort($order, SORT_ASC, $parts); return parent::normalizeQuery(implode('&', $parts)); }
php
protected static function normalizeQuery(?string $query): ?string { if (null === $query) { return null; } if ('' === $query) { return ''; } $parts = []; $order = []; // sort query params by key and remove missing keys foreach (explode('&', $query) as $param) { if ('' === $param || '=' === $param[0]) { continue; } $parts[] = $param; $kvp = explode('=', $param, 2); $order[] = $kvp[0]; } array_multisort($order, SORT_ASC, $parts); return parent::normalizeQuery(implode('&', $parts)); }
[ "protected", "static", "function", "normalizeQuery", "(", "?", "string", "$", "query", ")", ":", "?", "string", "{", "if", "(", "null", "===", "$", "query", ")", "{", "return", "null", ";", "}", "if", "(", "''", "===", "$", "query", ")", "{", "return", "''", ";", "}", "$", "parts", "=", "[", "]", ";", "$", "order", "=", "[", "]", ";", "// sort query params by key and remove missing keys", "foreach", "(", "explode", "(", "'&'", ",", "$", "query", ")", "as", "$", "param", ")", "{", "if", "(", "''", "===", "$", "param", "||", "'='", "===", "$", "param", "[", "0", "]", ")", "{", "continue", ";", "}", "$", "parts", "[", "]", "=", "$", "param", ";", "$", "kvp", "=", "explode", "(", "'='", ",", "$", "param", ",", "2", ")", ";", "$", "order", "[", "]", "=", "$", "kvp", "[", "0", "]", ";", "}", "array_multisort", "(", "$", "order", ",", "SORT_ASC", ",", "$", "parts", ")", ";", "return", "parent", "::", "normalizeQuery", "(", "implode", "(", "'&'", ",", "$", "parts", ")", ")", ";", "}" ]
Normalizes the query Sorts query by key and removes values without keys. @param string|null $query The query @return string|null
[ "Normalizes", "the", "query" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/Identifier/Url.php#L33-L59
7,113
edunola13/enolaphp-framework
src/Http/HttpCore.php
HttpCore.mappingController
public function mappingController($uriapp = NULL, $method = NULL){ $controllers= $this->app->context->getControllersDefinition(); $maps= FALSE; //Recorre todos los controladores principales hasta que uno coincida con la URI actual foreach ($controllers as $url => $controller_esp) { //Analiza si el controlador mapea con la uri actual $controller_esp['url']= strpos($url, '@') ? substr($url, 0, strpos($url, '@')) : $url; $mapController= $this->mapsController($controller_esp, $uriapp, $method); if($mapController == NULL && isset($controller_esp['routes'])){ foreach ($controller_esp['routes'] as $url => $controller_esp_2) { $controller_esp_2['url']= strpos($url, '@') ? substr($url, 0, strpos($url, '@')) : $url; $mapController= $this->mapsController($controller_esp_2, $uriapp, $method, $controller_esp); if($mapController != NULL){ break; } } } if($mapController != NULL){ return $mapController; } } //si ningun controlador mapeo avisa el problema if(! $maps){ Error::error_404(); } }
php
public function mappingController($uriapp = NULL, $method = NULL){ $controllers= $this->app->context->getControllersDefinition(); $maps= FALSE; //Recorre todos los controladores principales hasta que uno coincida con la URI actual foreach ($controllers as $url => $controller_esp) { //Analiza si el controlador mapea con la uri actual $controller_esp['url']= strpos($url, '@') ? substr($url, 0, strpos($url, '@')) : $url; $mapController= $this->mapsController($controller_esp, $uriapp, $method); if($mapController == NULL && isset($controller_esp['routes'])){ foreach ($controller_esp['routes'] as $url => $controller_esp_2) { $controller_esp_2['url']= strpos($url, '@') ? substr($url, 0, strpos($url, '@')) : $url; $mapController= $this->mapsController($controller_esp_2, $uriapp, $method, $controller_esp); if($mapController != NULL){ break; } } } if($mapController != NULL){ return $mapController; } } //si ningun controlador mapeo avisa el problema if(! $maps){ Error::error_404(); } }
[ "public", "function", "mappingController", "(", "$", "uriapp", "=", "NULL", ",", "$", "method", "=", "NULL", ")", "{", "$", "controllers", "=", "$", "this", "->", "app", "->", "context", "->", "getControllersDefinition", "(", ")", ";", "$", "maps", "=", "FALSE", ";", "//Recorre todos los controladores principales hasta que uno coincida con la URI actual", "foreach", "(", "$", "controllers", "as", "$", "url", "=>", "$", "controller_esp", ")", "{", "//Analiza si el controlador mapea con la uri actual", "$", "controller_esp", "[", "'url'", "]", "=", "strpos", "(", "$", "url", ",", "'@'", ")", "?", "substr", "(", "$", "url", ",", "0", ",", "strpos", "(", "$", "url", ",", "'@'", ")", ")", ":", "$", "url", ";", "$", "mapController", "=", "$", "this", "->", "mapsController", "(", "$", "controller_esp", ",", "$", "uriapp", ",", "$", "method", ")", ";", "if", "(", "$", "mapController", "==", "NULL", "&&", "isset", "(", "$", "controller_esp", "[", "'routes'", "]", ")", ")", "{", "foreach", "(", "$", "controller_esp", "[", "'routes'", "]", "as", "$", "url", "=>", "$", "controller_esp_2", ")", "{", "$", "controller_esp_2", "[", "'url'", "]", "=", "strpos", "(", "$", "url", ",", "'@'", ")", "?", "substr", "(", "$", "url", ",", "0", ",", "strpos", "(", "$", "url", ",", "'@'", ")", ")", ":", "$", "url", ";", "$", "mapController", "=", "$", "this", "->", "mapsController", "(", "$", "controller_esp_2", ",", "$", "uriapp", ",", "$", "method", ",", "$", "controller_esp", ")", ";", "if", "(", "$", "mapController", "!=", "NULL", ")", "{", "break", ";", "}", "}", "}", "if", "(", "$", "mapController", "!=", "NULL", ")", "{", "return", "$", "mapController", ";", "}", "}", "//si ningun controlador mapeo avisa el problema", "if", "(", "!", "$", "maps", ")", "{", "Error", "::", "error_404", "(", ")", ";", "}", "}" ]
Retorna la especificacion del controlador que mapea con la URI actual Levanta error 404 si ningun controlador mapea @param string $uriapp @return array
[ "Retorna", "la", "especificacion", "del", "controlador", "que", "mapea", "con", "la", "URI", "actual", "Levanta", "error", "404", "si", "ningun", "controlador", "mapea" ]
a962bfcd53d7bc129d8c9946aaa71d264285229d
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/Http/HttpCore.php#L45-L71
7,114
edunola13/enolaphp-framework
src/Http/HttpCore.php
HttpCore.mapsController
private function mapsController($controller, $uriapp = NULL, $method = NULL, $parentController = NULL){ $httpMethod= isset($controller['httpMethod']) ? $controller['httpMethod'] : '*'; if($parentController != NULL){ $controller['url']= rtrim($parentController['url'], '/') . '/' . ltrim($controller['url'], '/'); } $maps= UrlUri::mapsActualUrl($controller['url'], $uriapp) && UrlUri::mapsActualMethod($httpMethod, $method); if($maps){ $mapController= array( 'url' => $controller['url'], 'httpMethod' => $httpMethod, 'location' => isset($controller['location']) ? $controller['location'] : NULL, 'namespace' => isset($controller['namespace']) ? $controller['namespace'] : NULL, 'class' => isset($controller['class']) ? $controller['class'] : $parentController['class'], 'method' => isset($controller['method']) ? $controller['method'] : NULL, 'properties' => isset($controller['properties']) ? $controller['properties'] : array(), 'middlewares' => isset($controller['middlewares']) ? $controller['middlewares'] : [] ); if($parentController != NULL){ if(! isset($controller['class'])){ $mapController['location']= isset($parentController['location']) ? $parentController['location'] : NULL; $mapController['namespace']= isset($parentController['namespace']) ? $parentController['namespace'] : NULL; } if(isset($parentController['properties'])){ $mapController['properties']= array_merge($parentController['properties'], $mapController['properties']); } if(isset($parentController['middlewares'])){ $mapController['middlewares'] = array_merge($parentController['middlewares'], $mapController['middlewares']); } } return $mapController; }else{ return NULL; } }
php
private function mapsController($controller, $uriapp = NULL, $method = NULL, $parentController = NULL){ $httpMethod= isset($controller['httpMethod']) ? $controller['httpMethod'] : '*'; if($parentController != NULL){ $controller['url']= rtrim($parentController['url'], '/') . '/' . ltrim($controller['url'], '/'); } $maps= UrlUri::mapsActualUrl($controller['url'], $uriapp) && UrlUri::mapsActualMethod($httpMethod, $method); if($maps){ $mapController= array( 'url' => $controller['url'], 'httpMethod' => $httpMethod, 'location' => isset($controller['location']) ? $controller['location'] : NULL, 'namespace' => isset($controller['namespace']) ? $controller['namespace'] : NULL, 'class' => isset($controller['class']) ? $controller['class'] : $parentController['class'], 'method' => isset($controller['method']) ? $controller['method'] : NULL, 'properties' => isset($controller['properties']) ? $controller['properties'] : array(), 'middlewares' => isset($controller['middlewares']) ? $controller['middlewares'] : [] ); if($parentController != NULL){ if(! isset($controller['class'])){ $mapController['location']= isset($parentController['location']) ? $parentController['location'] : NULL; $mapController['namespace']= isset($parentController['namespace']) ? $parentController['namespace'] : NULL; } if(isset($parentController['properties'])){ $mapController['properties']= array_merge($parentController['properties'], $mapController['properties']); } if(isset($parentController['middlewares'])){ $mapController['middlewares'] = array_merge($parentController['middlewares'], $mapController['middlewares']); } } return $mapController; }else{ return NULL; } }
[ "private", "function", "mapsController", "(", "$", "controller", ",", "$", "uriapp", "=", "NULL", ",", "$", "method", "=", "NULL", ",", "$", "parentController", "=", "NULL", ")", "{", "$", "httpMethod", "=", "isset", "(", "$", "controller", "[", "'httpMethod'", "]", ")", "?", "$", "controller", "[", "'httpMethod'", "]", ":", "'*'", ";", "if", "(", "$", "parentController", "!=", "NULL", ")", "{", "$", "controller", "[", "'url'", "]", "=", "rtrim", "(", "$", "parentController", "[", "'url'", "]", ",", "'/'", ")", ".", "'/'", ".", "ltrim", "(", "$", "controller", "[", "'url'", "]", ",", "'/'", ")", ";", "}", "$", "maps", "=", "UrlUri", "::", "mapsActualUrl", "(", "$", "controller", "[", "'url'", "]", ",", "$", "uriapp", ")", "&&", "UrlUri", "::", "mapsActualMethod", "(", "$", "httpMethod", ",", "$", "method", ")", ";", "if", "(", "$", "maps", ")", "{", "$", "mapController", "=", "array", "(", "'url'", "=>", "$", "controller", "[", "'url'", "]", ",", "'httpMethod'", "=>", "$", "httpMethod", ",", "'location'", "=>", "isset", "(", "$", "controller", "[", "'location'", "]", ")", "?", "$", "controller", "[", "'location'", "]", ":", "NULL", ",", "'namespace'", "=>", "isset", "(", "$", "controller", "[", "'namespace'", "]", ")", "?", "$", "controller", "[", "'namespace'", "]", ":", "NULL", ",", "'class'", "=>", "isset", "(", "$", "controller", "[", "'class'", "]", ")", "?", "$", "controller", "[", "'class'", "]", ":", "$", "parentController", "[", "'class'", "]", ",", "'method'", "=>", "isset", "(", "$", "controller", "[", "'method'", "]", ")", "?", "$", "controller", "[", "'method'", "]", ":", "NULL", ",", "'properties'", "=>", "isset", "(", "$", "controller", "[", "'properties'", "]", ")", "?", "$", "controller", "[", "'properties'", "]", ":", "array", "(", ")", ",", "'middlewares'", "=>", "isset", "(", "$", "controller", "[", "'middlewares'", "]", ")", "?", "$", "controller", "[", "'middlewares'", "]", ":", "[", "]", ")", ";", "if", "(", "$", "parentController", "!=", "NULL", ")", "{", "if", "(", "!", "isset", "(", "$", "controller", "[", "'class'", "]", ")", ")", "{", "$", "mapController", "[", "'location'", "]", "=", "isset", "(", "$", "parentController", "[", "'location'", "]", ")", "?", "$", "parentController", "[", "'location'", "]", ":", "NULL", ";", "$", "mapController", "[", "'namespace'", "]", "=", "isset", "(", "$", "parentController", "[", "'namespace'", "]", ")", "?", "$", "parentController", "[", "'namespace'", "]", ":", "NULL", ";", "}", "if", "(", "isset", "(", "$", "parentController", "[", "'properties'", "]", ")", ")", "{", "$", "mapController", "[", "'properties'", "]", "=", "array_merge", "(", "$", "parentController", "[", "'properties'", "]", ",", "$", "mapController", "[", "'properties'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "parentController", "[", "'middlewares'", "]", ")", ")", "{", "$", "mapController", "[", "'middlewares'", "]", "=", "array_merge", "(", "$", "parentController", "[", "'middlewares'", "]", ",", "$", "mapController", "[", "'middlewares'", "]", ")", ";", "}", "}", "return", "$", "mapController", ";", "}", "else", "{", "return", "NULL", ";", "}", "}" ]
Controla si el controlador pasado mapea con la url y el metodo actual. En caso de mapear arma la especificacion del controlador. @param mixed $controller @param string $uriapp @param string $method @param mixed $parentController @return mixed
[ "Controla", "si", "el", "controlador", "pasado", "mapea", "con", "la", "url", "y", "el", "metodo", "actual", ".", "En", "caso", "de", "mapear", "arma", "la", "especificacion", "del", "controlador", "." ]
a962bfcd53d7bc129d8c9946aaa71d264285229d
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/Http/HttpCore.php#L81-L115
7,115
edunola13/enolaphp-framework
src/Http/HttpCore.php
HttpCore.executeHttpRequest
public function executeHttpRequest($actualController = NULL, $uriapp = NULL, $filter = TRUE){ //Si no se paso controlador, se busca el correspondiente if($actualController == NULL){ $actualController= $this->mappingController($uriapp); } //Ejecuto los filtros pre-procesamiento $rtaFilters= true; if($filter){ $rtaFilters= $this->executeFilters($this->app->context->getFiltersBeforeDefinition()); } //Controlo que desde un filtro no se haya parado la ejecucion if($rtaFilters !== false){ //Ejecuto el controlador $this->executeController($actualController, $uriapp); //Ejecuto los filtros post-procesamiento if($filter){ $this->executeFilters($this->app->context->getFiltersAfterDefinition()); } } }
php
public function executeHttpRequest($actualController = NULL, $uriapp = NULL, $filter = TRUE){ //Si no se paso controlador, se busca el correspondiente if($actualController == NULL){ $actualController= $this->mappingController($uriapp); } //Ejecuto los filtros pre-procesamiento $rtaFilters= true; if($filter){ $rtaFilters= $this->executeFilters($this->app->context->getFiltersBeforeDefinition()); } //Controlo que desde un filtro no se haya parado la ejecucion if($rtaFilters !== false){ //Ejecuto el controlador $this->executeController($actualController, $uriapp); //Ejecuto los filtros post-procesamiento if($filter){ $this->executeFilters($this->app->context->getFiltersAfterDefinition()); } } }
[ "public", "function", "executeHttpRequest", "(", "$", "actualController", "=", "NULL", ",", "$", "uriapp", "=", "NULL", ",", "$", "filter", "=", "TRUE", ")", "{", "//Si no se paso controlador, se busca el correspondiente", "if", "(", "$", "actualController", "==", "NULL", ")", "{", "$", "actualController", "=", "$", "this", "->", "mappingController", "(", "$", "uriapp", ")", ";", "}", "//Ejecuto los filtros pre-procesamiento", "$", "rtaFilters", "=", "true", ";", "if", "(", "$", "filter", ")", "{", "$", "rtaFilters", "=", "$", "this", "->", "executeFilters", "(", "$", "this", "->", "app", "->", "context", "->", "getFiltersBeforeDefinition", "(", ")", ")", ";", "}", "//Controlo que desde un filtro no se haya parado la ejecucion", "if", "(", "$", "rtaFilters", "!==", "false", ")", "{", "//Ejecuto el controlador", "$", "this", "->", "executeController", "(", "$", "actualController", ",", "$", "uriapp", ")", ";", "//Ejecuto los filtros post-procesamiento", "if", "(", "$", "filter", ")", "{", "$", "this", "->", "executeFilters", "(", "$", "this", "->", "app", "->", "context", "->", "getFiltersAfterDefinition", "(", ")", ")", ";", "}", "}", "}" ]
Ejecuta la especificacion de controlador pasada como parametro en base a una URI ejecutando o no filtros. En caso de que no se le pase el controlador lo consigue en base a la URI y en caso de que no se pase la URI especifica se usa la de la peticion actual. @param array $actualController @param string $uriapp @param boolean $filter
[ "Ejecuta", "la", "especificacion", "de", "controlador", "pasada", "como", "parametro", "en", "base", "a", "una", "URI", "ejecutando", "o", "no", "filtros", ".", "En", "caso", "de", "que", "no", "se", "le", "pase", "el", "controlador", "lo", "consigue", "en", "base", "a", "la", "URI", "y", "en", "caso", "de", "que", "no", "se", "pase", "la", "URI", "especifica", "se", "usa", "la", "de", "la", "peticion", "actual", "." ]
a962bfcd53d7bc129d8c9946aaa71d264285229d
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/Http/HttpCore.php#L124-L143
7,116
edunola13/enolaphp-framework
src/Http/HttpCore.php
HttpCore.executeFilters
protected function executeFilters($filters, $uriapp = NULL){ //Analizo los filtros y los aplico en caso de que corresponda foreach ($filters as $filter_esp) { $filter= UrlUri::mapsActualUrl($filter_esp['filtered'], $uriapp); //Si debe filtrar carga el filtro correspondiente y realiza el llamo al metodo filtrar() if($filter){ $dir= $this->buildDir($filter_esp,'filters'); $class= $this->buildClass($filter_esp); if(!class_exists($class)){ //Si la clase no existe intento cargarla if(file_exists($dir)){ require_once $dir; }else{ //Avisa que el archivo no existe Error::general_error('Filter Error', 'The filter ' . $filter_esp['class'] . ' dont exists'); } } $filterIns= new $class(); //Analizo si hay parametros en la configuracion if(isset($filter_esp['properties'])){ $this->app->dependenciesEngine->injectProperties($filterIns, $filter_esp['properties']); } //Analiza si existe el metodo filtrar if(method_exists($filterIns, 'filter')){ $rta= $filterIns->filter($this->httpRequest, $this->httpResponse); if($rta === false){ return false; } } else{ Error::general_error('Filter Error', 'The filter ' . $filter_esp['class'] . ' dont implement the method filter()'); } } } }
php
protected function executeFilters($filters, $uriapp = NULL){ //Analizo los filtros y los aplico en caso de que corresponda foreach ($filters as $filter_esp) { $filter= UrlUri::mapsActualUrl($filter_esp['filtered'], $uriapp); //Si debe filtrar carga el filtro correspondiente y realiza el llamo al metodo filtrar() if($filter){ $dir= $this->buildDir($filter_esp,'filters'); $class= $this->buildClass($filter_esp); if(!class_exists($class)){ //Si la clase no existe intento cargarla if(file_exists($dir)){ require_once $dir; }else{ //Avisa que el archivo no existe Error::general_error('Filter Error', 'The filter ' . $filter_esp['class'] . ' dont exists'); } } $filterIns= new $class(); //Analizo si hay parametros en la configuracion if(isset($filter_esp['properties'])){ $this->app->dependenciesEngine->injectProperties($filterIns, $filter_esp['properties']); } //Analiza si existe el metodo filtrar if(method_exists($filterIns, 'filter')){ $rta= $filterIns->filter($this->httpRequest, $this->httpResponse); if($rta === false){ return false; } } else{ Error::general_error('Filter Error', 'The filter ' . $filter_esp['class'] . ' dont implement the method filter()'); } } } }
[ "protected", "function", "executeFilters", "(", "$", "filters", ",", "$", "uriapp", "=", "NULL", ")", "{", "//Analizo los filtros y los aplico en caso de que corresponda", "foreach", "(", "$", "filters", "as", "$", "filter_esp", ")", "{", "$", "filter", "=", "UrlUri", "::", "mapsActualUrl", "(", "$", "filter_esp", "[", "'filtered'", "]", ",", "$", "uriapp", ")", ";", "//Si debe filtrar carga el filtro correspondiente y realiza el llamo al metodo filtrar()", "if", "(", "$", "filter", ")", "{", "$", "dir", "=", "$", "this", "->", "buildDir", "(", "$", "filter_esp", ",", "'filters'", ")", ";", "$", "class", "=", "$", "this", "->", "buildClass", "(", "$", "filter_esp", ")", ";", "if", "(", "!", "class_exists", "(", "$", "class", ")", ")", "{", "//Si la clase no existe intento cargarla", "if", "(", "file_exists", "(", "$", "dir", ")", ")", "{", "require_once", "$", "dir", ";", "}", "else", "{", "//Avisa que el archivo no existe", "Error", "::", "general_error", "(", "'Filter Error'", ",", "'The filter '", ".", "$", "filter_esp", "[", "'class'", "]", ".", "' dont exists'", ")", ";", "}", "}", "$", "filterIns", "=", "new", "$", "class", "(", ")", ";", "//Analizo si hay parametros en la configuracion", "if", "(", "isset", "(", "$", "filter_esp", "[", "'properties'", "]", ")", ")", "{", "$", "this", "->", "app", "->", "dependenciesEngine", "->", "injectProperties", "(", "$", "filterIns", ",", "$", "filter_esp", "[", "'properties'", "]", ")", ";", "}", "//Analiza si existe el metodo filtrar", "if", "(", "method_exists", "(", "$", "filterIns", ",", "'filter'", ")", ")", "{", "$", "rta", "=", "$", "filterIns", "->", "filter", "(", "$", "this", "->", "httpRequest", ",", "$", "this", "->", "httpResponse", ")", ";", "if", "(", "$", "rta", "===", "false", ")", "{", "return", "false", ";", "}", "}", "else", "{", "Error", "::", "general_error", "(", "'Filter Error'", ",", "'The filter '", ".", "$", "filter_esp", "[", "'class'", "]", ".", "' dont implement the method filter()'", ")", ";", "}", "}", "}", "}" ]
Analiza los filtros que mapean con la URI pasada y ejecuta los que correspondan. En caso de no pasar URI se utiliza la de la peticion actual. @param array[array] $filters @param string $uriapp
[ "Analiza", "los", "filtros", "que", "mapean", "con", "la", "URI", "pasada", "y", "ejecuta", "los", "que", "correspondan", ".", "En", "caso", "de", "no", "pasar", "URI", "se", "utiliza", "la", "de", "la", "peticion", "actual", "." ]
a962bfcd53d7bc129d8c9946aaa71d264285229d
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/Http/HttpCore.php#L150-L184
7,117
edunola13/enolaphp-framework
src/Http/HttpCore.php
HttpCore.executeMiddlewares
protected function executeMiddlewares($middlewares){ //Analizo los filtros y los aplico en caso de que corresponda $middlewaresDefinition = $this->app->context->getMiddlewaresDefinition(); foreach ($middlewares as $middlewareName) { if (! isset($middlewaresDefinition[$middlewareName])) { Error::general_error('Middleware Error', 'The middleware ' . $middlewareName . ' dont exists'); } $middleware = $middlewaresDefinition[$middlewareName]; $dir = $this->buildDir($middleware, 'middlewares'); $class = $this->buildClass($middleware); if(!class_exists($class)){ //Si la clase no existe intento cargarla if(file_exists($dir)){ require_once $dir; }else{ //Avisa que el archivo no existe Error::general_error('Middleware Error', 'The middleware ' . $middleware['class'] . ' dont exists'); } } $middlewareIns= new $class(); //Analizo si hay parametros en la configuracion if(isset($middleware['properties'])){ $this->app->dependenciesEngine->injectProperties($middlewareIns, $middleware['properties']); } //Analiza si existe el metodo filtrar if(method_exists($middlewareIns, 'handle')){ $rta= $middlewareIns->handle($this->httpRequest, $this->httpResponse); if($rta === false){ return false; } } else{ Error::general_error('Middleware Error', 'The middleware ' . $middleware['class'] . ' dont implement the method handle()'); } } }
php
protected function executeMiddlewares($middlewares){ //Analizo los filtros y los aplico en caso de que corresponda $middlewaresDefinition = $this->app->context->getMiddlewaresDefinition(); foreach ($middlewares as $middlewareName) { if (! isset($middlewaresDefinition[$middlewareName])) { Error::general_error('Middleware Error', 'The middleware ' . $middlewareName . ' dont exists'); } $middleware = $middlewaresDefinition[$middlewareName]; $dir = $this->buildDir($middleware, 'middlewares'); $class = $this->buildClass($middleware); if(!class_exists($class)){ //Si la clase no existe intento cargarla if(file_exists($dir)){ require_once $dir; }else{ //Avisa que el archivo no existe Error::general_error('Middleware Error', 'The middleware ' . $middleware['class'] . ' dont exists'); } } $middlewareIns= new $class(); //Analizo si hay parametros en la configuracion if(isset($middleware['properties'])){ $this->app->dependenciesEngine->injectProperties($middlewareIns, $middleware['properties']); } //Analiza si existe el metodo filtrar if(method_exists($middlewareIns, 'handle')){ $rta= $middlewareIns->handle($this->httpRequest, $this->httpResponse); if($rta === false){ return false; } } else{ Error::general_error('Middleware Error', 'The middleware ' . $middleware['class'] . ' dont implement the method handle()'); } } }
[ "protected", "function", "executeMiddlewares", "(", "$", "middlewares", ")", "{", "//Analizo los filtros y los aplico en caso de que corresponda", "$", "middlewaresDefinition", "=", "$", "this", "->", "app", "->", "context", "->", "getMiddlewaresDefinition", "(", ")", ";", "foreach", "(", "$", "middlewares", "as", "$", "middlewareName", ")", "{", "if", "(", "!", "isset", "(", "$", "middlewaresDefinition", "[", "$", "middlewareName", "]", ")", ")", "{", "Error", "::", "general_error", "(", "'Middleware Error'", ",", "'The middleware '", ".", "$", "middlewareName", ".", "' dont exists'", ")", ";", "}", "$", "middleware", "=", "$", "middlewaresDefinition", "[", "$", "middlewareName", "]", ";", "$", "dir", "=", "$", "this", "->", "buildDir", "(", "$", "middleware", ",", "'middlewares'", ")", ";", "$", "class", "=", "$", "this", "->", "buildClass", "(", "$", "middleware", ")", ";", "if", "(", "!", "class_exists", "(", "$", "class", ")", ")", "{", "//Si la clase no existe intento cargarla", "if", "(", "file_exists", "(", "$", "dir", ")", ")", "{", "require_once", "$", "dir", ";", "}", "else", "{", "//Avisa que el archivo no existe", "Error", "::", "general_error", "(", "'Middleware Error'", ",", "'The middleware '", ".", "$", "middleware", "[", "'class'", "]", ".", "' dont exists'", ")", ";", "}", "}", "$", "middlewareIns", "=", "new", "$", "class", "(", ")", ";", "//Analizo si hay parametros en la configuracion", "if", "(", "isset", "(", "$", "middleware", "[", "'properties'", "]", ")", ")", "{", "$", "this", "->", "app", "->", "dependenciesEngine", "->", "injectProperties", "(", "$", "middlewareIns", ",", "$", "middleware", "[", "'properties'", "]", ")", ";", "}", "//Analiza si existe el metodo filtrar", "if", "(", "method_exists", "(", "$", "middlewareIns", ",", "'handle'", ")", ")", "{", "$", "rta", "=", "$", "middlewareIns", "->", "handle", "(", "$", "this", "->", "httpRequest", ",", "$", "this", "->", "httpResponse", ")", ";", "if", "(", "$", "rta", "===", "false", ")", "{", "return", "false", ";", "}", "}", "else", "{", "Error", "::", "general_error", "(", "'Middleware Error'", ",", "'The middleware '", ".", "$", "middleware", "[", "'class'", "]", ".", "' dont implement the method handle()'", ")", ";", "}", "}", "}" ]
Se ejecutan los middlewares que se pasan como parametro @param array[string] $filters @param string $uriapp
[ "Se", "ejecutan", "los", "middlewares", "que", "se", "pasan", "como", "parametro" ]
a962bfcd53d7bc129d8c9946aaa71d264285229d
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/Http/HttpCore.php#L190-L227
7,118
edunola13/enolaphp-framework
src/Http/HttpCore.php
HttpCore.executeController
protected function executeController($controller_esp, $uriapp = NULL) { if (count($controller_esp['middlewares']) > 0) { if ($this->executeMiddlewares($controller_esp['middlewares']) === false) { return; } } $dir= $this->buildDir($controller_esp); $class= $this->buildClass($controller_esp); if(!class_exists($class)){ //Si la clase no existe intento cargarla if(file_exists($dir)){ require_once $dir; }else{ //Avisa que el archivo no existe Error::general_error('Controller Error', 'The controller ' . $controller_esp['class'] . ' dont exists'); } } $controller= new $class(); //Agrego los parametros URI $uri_params= UrlUri::uriParams($controller_esp['url'], $uriapp); $dinamic_method= $uri_params['dinamic']; $method= $uri_params['method']; $parameters= $uri_params['params'] ? $uri_params['params'] : array(); //Analizo si hay parametros en la configuracion if(isset($controller_esp['properties'])){ $this->app->dependenciesEngine->injectProperties($controller, $controller_esp['properties']); } //Saca el metodo HTPP y en base a eso hace una llamada al metodo correspondiente $methodHttp= filter_input(INPUT_SERVER, 'REQUEST_METHOD'); if($dinamic_method){ if($method != 'index' && !(method_exists($controller, $methodHttp . '_' . $method) || method_exists($controller, $method))){ $parameters= array_merge(array('0' => $method), $parameters); $method= 'index'; } if(method_exists($controller, $methodHttp . '_' . $method)){ $method= $methodHttp . '_' . $method; } }else if(isset($controller_esp['method'])){ $method= $controller_esp['method']; }else{ $method= "do" . ucfirst(strtolower($methodHttp)); } $controller->setUriParams($parameters); if(method_exists($controller, $method)){ $controller->$method($this->httpRequest, $this->httpResponse); }else{ Error::general_error('HTTP Method Error', "The HTTP method $method is not supported"); } }
php
protected function executeController($controller_esp, $uriapp = NULL) { if (count($controller_esp['middlewares']) > 0) { if ($this->executeMiddlewares($controller_esp['middlewares']) === false) { return; } } $dir= $this->buildDir($controller_esp); $class= $this->buildClass($controller_esp); if(!class_exists($class)){ //Si la clase no existe intento cargarla if(file_exists($dir)){ require_once $dir; }else{ //Avisa que el archivo no existe Error::general_error('Controller Error', 'The controller ' . $controller_esp['class'] . ' dont exists'); } } $controller= new $class(); //Agrego los parametros URI $uri_params= UrlUri::uriParams($controller_esp['url'], $uriapp); $dinamic_method= $uri_params['dinamic']; $method= $uri_params['method']; $parameters= $uri_params['params'] ? $uri_params['params'] : array(); //Analizo si hay parametros en la configuracion if(isset($controller_esp['properties'])){ $this->app->dependenciesEngine->injectProperties($controller, $controller_esp['properties']); } //Saca el metodo HTPP y en base a eso hace una llamada al metodo correspondiente $methodHttp= filter_input(INPUT_SERVER, 'REQUEST_METHOD'); if($dinamic_method){ if($method != 'index' && !(method_exists($controller, $methodHttp . '_' . $method) || method_exists($controller, $method))){ $parameters= array_merge(array('0' => $method), $parameters); $method= 'index'; } if(method_exists($controller, $methodHttp . '_' . $method)){ $method= $methodHttp . '_' . $method; } }else if(isset($controller_esp['method'])){ $method= $controller_esp['method']; }else{ $method= "do" . ucfirst(strtolower($methodHttp)); } $controller->setUriParams($parameters); if(method_exists($controller, $method)){ $controller->$method($this->httpRequest, $this->httpResponse); }else{ Error::general_error('HTTP Method Error', "The HTTP method $method is not supported"); } }
[ "protected", "function", "executeController", "(", "$", "controller_esp", ",", "$", "uriapp", "=", "NULL", ")", "{", "if", "(", "count", "(", "$", "controller_esp", "[", "'middlewares'", "]", ")", ">", "0", ")", "{", "if", "(", "$", "this", "->", "executeMiddlewares", "(", "$", "controller_esp", "[", "'middlewares'", "]", ")", "===", "false", ")", "{", "return", ";", "}", "}", "$", "dir", "=", "$", "this", "->", "buildDir", "(", "$", "controller_esp", ")", ";", "$", "class", "=", "$", "this", "->", "buildClass", "(", "$", "controller_esp", ")", ";", "if", "(", "!", "class_exists", "(", "$", "class", ")", ")", "{", "//Si la clase no existe intento cargarla", "if", "(", "file_exists", "(", "$", "dir", ")", ")", "{", "require_once", "$", "dir", ";", "}", "else", "{", "//Avisa que el archivo no existe", "Error", "::", "general_error", "(", "'Controller Error'", ",", "'The controller '", ".", "$", "controller_esp", "[", "'class'", "]", ".", "' dont exists'", ")", ";", "}", "}", "$", "controller", "=", "new", "$", "class", "(", ")", ";", "//Agrego los parametros URI", "$", "uri_params", "=", "UrlUri", "::", "uriParams", "(", "$", "controller_esp", "[", "'url'", "]", ",", "$", "uriapp", ")", ";", "$", "dinamic_method", "=", "$", "uri_params", "[", "'dinamic'", "]", ";", "$", "method", "=", "$", "uri_params", "[", "'method'", "]", ";", "$", "parameters", "=", "$", "uri_params", "[", "'params'", "]", "?", "$", "uri_params", "[", "'params'", "]", ":", "array", "(", ")", ";", "//Analizo si hay parametros en la configuracion", "if", "(", "isset", "(", "$", "controller_esp", "[", "'properties'", "]", ")", ")", "{", "$", "this", "->", "app", "->", "dependenciesEngine", "->", "injectProperties", "(", "$", "controller", ",", "$", "controller_esp", "[", "'properties'", "]", ")", ";", "}", "//Saca el metodo HTPP y en base a eso hace una llamada al metodo correspondiente", "$", "methodHttp", "=", "filter_input", "(", "INPUT_SERVER", ",", "'REQUEST_METHOD'", ")", ";", "if", "(", "$", "dinamic_method", ")", "{", "if", "(", "$", "method", "!=", "'index'", "&&", "!", "(", "method_exists", "(", "$", "controller", ",", "$", "methodHttp", ".", "'_'", ".", "$", "method", ")", "||", "method_exists", "(", "$", "controller", ",", "$", "method", ")", ")", ")", "{", "$", "parameters", "=", "array_merge", "(", "array", "(", "'0'", "=>", "$", "method", ")", ",", "$", "parameters", ")", ";", "$", "method", "=", "'index'", ";", "}", "if", "(", "method_exists", "(", "$", "controller", ",", "$", "methodHttp", ".", "'_'", ".", "$", "method", ")", ")", "{", "$", "method", "=", "$", "methodHttp", ".", "'_'", ".", "$", "method", ";", "}", "}", "else", "if", "(", "isset", "(", "$", "controller_esp", "[", "'method'", "]", ")", ")", "{", "$", "method", "=", "$", "controller_esp", "[", "'method'", "]", ";", "}", "else", "{", "$", "method", "=", "\"do\"", ".", "ucfirst", "(", "strtolower", "(", "$", "methodHttp", ")", ")", ";", "}", "$", "controller", "->", "setUriParams", "(", "$", "parameters", ")", ";", "if", "(", "method_exists", "(", "$", "controller", ",", "$", "method", ")", ")", "{", "$", "controller", "->", "$", "method", "(", "$", "this", "->", "httpRequest", ",", "$", "this", "->", "httpResponse", ")", ";", "}", "else", "{", "Error", "::", "general_error", "(", "'HTTP Method Error'", ",", "\"The HTTP method $method is not supported\"", ")", ";", "}", "}" ]
Ejecuta el controlador que mapeo anteriormente. Segun su definicion en la configuracion se ejecutara al estilo REST o mediante nombre de funciones @param array $controller_esp @param string $uriapp
[ "Ejecuta", "el", "controlador", "que", "mapeo", "anteriormente", ".", "Segun", "su", "definicion", "en", "la", "configuracion", "se", "ejecutara", "al", "estilo", "REST", "o", "mediante", "nombre", "de", "funciones" ]
a962bfcd53d7bc129d8c9946aaa71d264285229d
https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/Http/HttpCore.php#L234-L283
7,119
mijohansen/php-gae-util
src/JWT.php
JWT.get
static public function get($email = null, $type) { static $cache; if (is_null($email)) { /** * Creating a token with the current module identity for reference. */ $email = Util::getModuleId() . "@" . Util::getApplicationId(); } if (is_null($cache[$email])) { $payload = [ "exp" => time() + 3.154e+7, "sub" => $email ]; $cache[$email] = \Firebase\JWT\JWT::encode($payload, self::getSecret($type), self::ALG); } return $cache[$email]; }
php
static public function get($email = null, $type) { static $cache; if (is_null($email)) { /** * Creating a token with the current module identity for reference. */ $email = Util::getModuleId() . "@" . Util::getApplicationId(); } if (is_null($cache[$email])) { $payload = [ "exp" => time() + 3.154e+7, "sub" => $email ]; $cache[$email] = \Firebase\JWT\JWT::encode($payload, self::getSecret($type), self::ALG); } return $cache[$email]; }
[ "static", "public", "function", "get", "(", "$", "email", "=", "null", ",", "$", "type", ")", "{", "static", "$", "cache", ";", "if", "(", "is_null", "(", "$", "email", ")", ")", "{", "/**\n * Creating a token with the current module identity for reference.\n */", "$", "email", "=", "Util", "::", "getModuleId", "(", ")", ".", "\"@\"", ".", "Util", "::", "getApplicationId", "(", ")", ";", "}", "if", "(", "is_null", "(", "$", "cache", "[", "$", "email", "]", ")", ")", "{", "$", "payload", "=", "[", "\"exp\"", "=>", "time", "(", ")", "+", "3.154e+7", ",", "\"sub\"", "=>", "$", "email", "]", ";", "$", "cache", "[", "$", "email", "]", "=", "\\", "Firebase", "\\", "JWT", "\\", "JWT", "::", "encode", "(", "$", "payload", ",", "self", "::", "getSecret", "(", "$", "type", ")", ",", "self", "::", "ALG", ")", ";", "}", "return", "$", "cache", "[", "$", "email", "]", ";", "}" ]
Returns a valid JWT token for this account
[ "Returns", "a", "valid", "JWT", "token", "for", "this", "account" ]
dfa7a1a4d61aa435351d6a5b1b120c0e23d81dde
https://github.com/mijohansen/php-gae-util/blob/dfa7a1a4d61aa435351d6a5b1b120c0e23d81dde/src/JWT.php#L34-L51
7,120
mijohansen/php-gae-util
src/JWT.php
JWT.getInternalToken
static public function getInternalToken() { static $token; if (is_null($token)) { $payload = [ "exp" => time() + Moment::ONEHOUR, "sub" => Util::getModuleId() . "@" . Util::getApplicationId() ]; $secret = self::getSecret(self::CONF_INTERNAL_SECRET_NAME); $token = \Firebase\JWT\JWT::encode($payload, $secret, self::ALG); } return $token; }
php
static public function getInternalToken() { static $token; if (is_null($token)) { $payload = [ "exp" => time() + Moment::ONEHOUR, "sub" => Util::getModuleId() . "@" . Util::getApplicationId() ]; $secret = self::getSecret(self::CONF_INTERNAL_SECRET_NAME); $token = \Firebase\JWT\JWT::encode($payload, $secret, self::ALG); } return $token; }
[ "static", "public", "function", "getInternalToken", "(", ")", "{", "static", "$", "token", ";", "if", "(", "is_null", "(", "$", "token", ")", ")", "{", "$", "payload", "=", "[", "\"exp\"", "=>", "time", "(", ")", "+", "Moment", "::", "ONEHOUR", ",", "\"sub\"", "=>", "Util", "::", "getModuleId", "(", ")", ".", "\"@\"", ".", "Util", "::", "getApplicationId", "(", ")", "]", ";", "$", "secret", "=", "self", "::", "getSecret", "(", "self", "::", "CONF_INTERNAL_SECRET_NAME", ")", ";", "$", "token", "=", "\\", "Firebase", "\\", "JWT", "\\", "JWT", "::", "encode", "(", "$", "payload", ",", "$", "secret", ",", "self", "::", "ALG", ")", ";", "}", "return", "$", "token", ";", "}" ]
Get Token used for service to service communication. Setting standard time to 5 seconds for internal service to service communication. @return string @throws \Exception
[ "Get", "Token", "used", "for", "service", "to", "service", "communication", ".", "Setting", "standard", "time", "to", "5", "seconds", "for", "internal", "service", "to", "service", "communication", "." ]
dfa7a1a4d61aa435351d6a5b1b120c0e23d81dde
https://github.com/mijohansen/php-gae-util/blob/dfa7a1a4d61aa435351d6a5b1b120c0e23d81dde/src/JWT.php#L60-L71
7,121
studyportals/Cache
src/FileCache.php
FileCache._getFileName
protected function _getFileName($name){ $name = trim($name); $name = iconv('ISO-8859-1', 'ASCII//TRANSLIT', $name); $name = preg_replace('/[^a-z0-9\-:]+/i', '_', $name); $name = str_replace(':', '.', $name); if($name == ''){ throw new CacheException('Cache-entry name cannot be empty'); } return "{$name}.cache"; }
php
protected function _getFileName($name){ $name = trim($name); $name = iconv('ISO-8859-1', 'ASCII//TRANSLIT', $name); $name = preg_replace('/[^a-z0-9\-:]+/i', '_', $name); $name = str_replace(':', '.', $name); if($name == ''){ throw new CacheException('Cache-entry name cannot be empty'); } return "{$name}.cache"; }
[ "protected", "function", "_getFileName", "(", "$", "name", ")", "{", "$", "name", "=", "trim", "(", "$", "name", ")", ";", "$", "name", "=", "iconv", "(", "'ISO-8859-1'", ",", "'ASCII//TRANSLIT'", ",", "$", "name", ")", ";", "$", "name", "=", "preg_replace", "(", "'/[^a-z0-9\\-:]+/i'", ",", "'_'", ",", "$", "name", ")", ";", "$", "name", "=", "str_replace", "(", "':'", ",", "'.'", ",", "$", "name", ")", ";", "if", "(", "$", "name", "==", "''", ")", "{", "throw", "new", "CacheException", "(", "'Cache-entry name cannot be empty'", ")", ";", "}", "return", "\"{$name}.cache\"", ";", "}" ]
Get a cache-entry filename based upon the string provided. @param string $name @return string @throws CacheException
[ "Get", "a", "cache", "-", "entry", "filename", "based", "upon", "the", "string", "provided", "." ]
f24264b18bea49e97fa8a630cdda595d5b026600
https://github.com/studyportals/Cache/blob/f24264b18bea49e97fa8a630cdda595d5b026600/src/FileCache.php#L60-L74
7,122
studyportals/Cache
src/FileCache.php
FileCache._clearExpired
protected function _clearExpired($time = null){ if($time === null) $time = time(); $files = glob("{$this->_cache_path}*.cache"); $cleared = 0; if(is_array($files)){ foreach($files as $file){ $path = $this->_cache_path . basename($file); $mtime = @filemtime($path); // Remove expired files if($mtime !== false && $time > $mtime){ @unlink($path); ++$cleared; } } } return $cleared; }
php
protected function _clearExpired($time = null){ if($time === null) $time = time(); $files = glob("{$this->_cache_path}*.cache"); $cleared = 0; if(is_array($files)){ foreach($files as $file){ $path = $this->_cache_path . basename($file); $mtime = @filemtime($path); // Remove expired files if($mtime !== false && $time > $mtime){ @unlink($path); ++$cleared; } } } return $cleared; }
[ "protected", "function", "_clearExpired", "(", "$", "time", "=", "null", ")", "{", "if", "(", "$", "time", "===", "null", ")", "$", "time", "=", "time", "(", ")", ";", "$", "files", "=", "glob", "(", "\"{$this->_cache_path}*.cache\"", ")", ";", "$", "cleared", "=", "0", ";", "if", "(", "is_array", "(", "$", "files", ")", ")", "{", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "path", "=", "$", "this", "->", "_cache_path", ".", "basename", "(", "$", "file", ")", ";", "$", "mtime", "=", "@", "filemtime", "(", "$", "path", ")", ";", "// Remove expired files", "if", "(", "$", "mtime", "!==", "false", "&&", "$", "time", ">", "$", "mtime", ")", "{", "@", "unlink", "(", "$", "path", ")", ";", "++", "$", "cleared", ";", "}", "}", "}", "return", "$", "cleared", ";", "}" ]
Clear expired cache-entries from the cache-path. <p>The optional parameter {@link $time} can be used to provide a reference time for the expiry. When omitted, the current time is used.</p> <p>Returns the number of expired items cleared from the cache.</p> @param integer $time @return integer
[ "Clear", "expired", "cache", "-", "entries", "from", "the", "cache", "-", "path", "." ]
f24264b18bea49e97fa8a630cdda595d5b026600
https://github.com/studyportals/Cache/blob/f24264b18bea49e97fa8a630cdda595d5b026600/src/FileCache.php#L89-L114
7,123
studyportals/Cache
src/FileCache.php
FileCache.set
public function set($name, $value, $ttl = 0){ if($ttl <= 0) $ttl = self::TTL_FUTURE; if(is_resource($value)){ throw new CacheException('Cannot cache values of type "resource"'); } if(!$this->validateValueSize($value)){ ExceptionHandler::notice("Value in $name is too big to be stored in file cache."); } $file = $this->_getFileName($name); $fp = @fopen($this->_cache_path . $file, 'wb'); if(is_resource($fp)){ $result = @fwrite($fp, serialize($value)); $result = ($result && @fclose($fp)); $result = ($result && @touch($this->_cache_path . $file, time() + $ttl)); // Clear expired cache-files every once-in-a-while if($result && rand(1, self::CLEAR_INTERVAL) == self::CLEAR_INTERVAL){ $this->_clearExpired(); } return $result; } else{ return false; } }
php
public function set($name, $value, $ttl = 0){ if($ttl <= 0) $ttl = self::TTL_FUTURE; if(is_resource($value)){ throw new CacheException('Cannot cache values of type "resource"'); } if(!$this->validateValueSize($value)){ ExceptionHandler::notice("Value in $name is too big to be stored in file cache."); } $file = $this->_getFileName($name); $fp = @fopen($this->_cache_path . $file, 'wb'); if(is_resource($fp)){ $result = @fwrite($fp, serialize($value)); $result = ($result && @fclose($fp)); $result = ($result && @touch($this->_cache_path . $file, time() + $ttl)); // Clear expired cache-files every once-in-a-while if($result && rand(1, self::CLEAR_INTERVAL) == self::CLEAR_INTERVAL){ $this->_clearExpired(); } return $result; } else{ return false; } }
[ "public", "function", "set", "(", "$", "name", ",", "$", "value", ",", "$", "ttl", "=", "0", ")", "{", "if", "(", "$", "ttl", "<=", "0", ")", "$", "ttl", "=", "self", "::", "TTL_FUTURE", ";", "if", "(", "is_resource", "(", "$", "value", ")", ")", "{", "throw", "new", "CacheException", "(", "'Cannot cache values of type \"resource\"'", ")", ";", "}", "if", "(", "!", "$", "this", "->", "validateValueSize", "(", "$", "value", ")", ")", "{", "ExceptionHandler", "::", "notice", "(", "\"Value in $name is too big to be stored in file cache.\"", ")", ";", "}", "$", "file", "=", "$", "this", "->", "_getFileName", "(", "$", "name", ")", ";", "$", "fp", "=", "@", "fopen", "(", "$", "this", "->", "_cache_path", ".", "$", "file", ",", "'wb'", ")", ";", "if", "(", "is_resource", "(", "$", "fp", ")", ")", "{", "$", "result", "=", "@", "fwrite", "(", "$", "fp", ",", "serialize", "(", "$", "value", ")", ")", ";", "$", "result", "=", "(", "$", "result", "&&", "@", "fclose", "(", "$", "fp", ")", ")", ";", "$", "result", "=", "(", "$", "result", "&&", "@", "touch", "(", "$", "this", "->", "_cache_path", ".", "$", "file", ",", "time", "(", ")", "+", "$", "ttl", ")", ")", ";", "// Clear expired cache-files every once-in-a-while", "if", "(", "$", "result", "&&", "rand", "(", "1", ",", "self", "::", "CLEAR_INTERVAL", ")", "==", "self", "::", "CLEAR_INTERVAL", ")", "{", "$", "this", "->", "_clearExpired", "(", ")", ";", "}", "return", "$", "result", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Add an entry to the FileCache. <p>Due to the way FileCache keeps track of expiry dates, setting {@link $ttl} to zero will set the expiry time to FileCache::TTL_FUTURE which by default is set to 365 days in the future.</p> <p>Every successful "set" has a chance of triggering {@link FileCache::_clearExpired()} which clears expired entries from the cache-path. The chance of trigging this method is controlled through the {@link FileCache::CLEAR_INTERVAL} constant. By default it will be triggered once every 50 sets.</p> @param string $name @param mixed $value @param integer $ttl @return boolean @throws CacheException @see Cache::set() @see FileCache::_clearExpired()
[ "Add", "an", "entry", "to", "the", "FileCache", "." ]
f24264b18bea49e97fa8a630cdda595d5b026600
https://github.com/studyportals/Cache/blob/f24264b18bea49e97fa8a630cdda595d5b026600/src/FileCache.php#L138-L178
7,124
studyportals/Cache
src/FileCache.php
FileCache.get
public function get($name, &$error = false){ // If disabled, return nothing so that this cache is overwritten if(!$this->_enabled){ return null; } try{ $file = $this->_getFileName($name); } catch(CacheException $e){ $error = true; return null; } if(time() > @filemtime($this->_cache_path . $file)){ return null; } $contents = @file_get_contents($this->_cache_path . $file); if($contents !== false){ error_clear_last(); $value = @unserialize($contents); // Attempt to separate serialised "false" from unserialisation errors $last_error = error_get_last(); if($value === false && $last_error !== null && $last_error['type'] === E_WARNING){ $error = true; return null; } return $value; } return null; }
php
public function get($name, &$error = false){ // If disabled, return nothing so that this cache is overwritten if(!$this->_enabled){ return null; } try{ $file = $this->_getFileName($name); } catch(CacheException $e){ $error = true; return null; } if(time() > @filemtime($this->_cache_path . $file)){ return null; } $contents = @file_get_contents($this->_cache_path . $file); if($contents !== false){ error_clear_last(); $value = @unserialize($contents); // Attempt to separate serialised "false" from unserialisation errors $last_error = error_get_last(); if($value === false && $last_error !== null && $last_error['type'] === E_WARNING){ $error = true; return null; } return $value; } return null; }
[ "public", "function", "get", "(", "$", "name", ",", "&", "$", "error", "=", "false", ")", "{", "// If disabled, return nothing so that this cache is overwritten", "if", "(", "!", "$", "this", "->", "_enabled", ")", "{", "return", "null", ";", "}", "try", "{", "$", "file", "=", "$", "this", "->", "_getFileName", "(", "$", "name", ")", ";", "}", "catch", "(", "CacheException", "$", "e", ")", "{", "$", "error", "=", "true", ";", "return", "null", ";", "}", "if", "(", "time", "(", ")", ">", "@", "filemtime", "(", "$", "this", "->", "_cache_path", ".", "$", "file", ")", ")", "{", "return", "null", ";", "}", "$", "contents", "=", "@", "file_get_contents", "(", "$", "this", "->", "_cache_path", ".", "$", "file", ")", ";", "if", "(", "$", "contents", "!==", "false", ")", "{", "error_clear_last", "(", ")", ";", "$", "value", "=", "@", "unserialize", "(", "$", "contents", ")", ";", "// Attempt to separate serialised \"false\" from unserialisation errors", "$", "last_error", "=", "error_get_last", "(", ")", ";", "if", "(", "$", "value", "===", "false", "&&", "$", "last_error", "!==", "null", "&&", "$", "last_error", "[", "'type'", "]", "===", "E_WARNING", ")", "{", "$", "error", "=", "true", ";", "return", "null", ";", "}", "return", "$", "value", ";", "}", "return", "null", ";", "}" ]
Get an entry from the FileCache. @param string $name @param boolean &$error @return mixed @see Cache::get()
[ "Get", "an", "entry", "from", "the", "FileCache", "." ]
f24264b18bea49e97fa8a630cdda595d5b026600
https://github.com/studyportals/Cache/blob/f24264b18bea49e97fa8a630cdda595d5b026600/src/FileCache.php#L189-L237
7,125
studyportals/Cache
src/FileCache.php
FileCache.delete
public function delete($name){ try{ $file = $this->_getFileName($name); } catch(CacheException $e){ return false; } return @unlink($this->_cache_path . $file); }
php
public function delete($name){ try{ $file = $this->_getFileName($name); } catch(CacheException $e){ return false; } return @unlink($this->_cache_path . $file); }
[ "public", "function", "delete", "(", "$", "name", ")", "{", "try", "{", "$", "file", "=", "$", "this", "->", "_getFileName", "(", "$", "name", ")", ";", "}", "catch", "(", "CacheException", "$", "e", ")", "{", "return", "false", ";", "}", "return", "@", "unlink", "(", "$", "this", "->", "_cache_path", ".", "$", "file", ")", ";", "}" ]
Delete an entry from the FileCache. @param string $name @return boolean @see Cache::delete()
[ "Delete", "an", "entry", "from", "the", "FileCache", "." ]
f24264b18bea49e97fa8a630cdda595d5b026600
https://github.com/studyportals/Cache/blob/f24264b18bea49e97fa8a630cdda595d5b026600/src/FileCache.php#L247-L259
7,126
schnittstabil/psr7-middleware-stack
src/MiddlewareStackTrait.php
MiddlewareStackTrait.push
protected function push(callable $newTopMiddleware) { $oldStack = $this->middlewareStack; if ($oldStack === null) { $this->middlewareStack = $newTopMiddleware; return $this; } $this->middlewareStack = function ($request, $response, callable $next) use ($oldStack, $newTopMiddleware) { return $newTopMiddleware($request, $response, function ($req, $res) use ($next, $oldStack) { return $oldStack($req, $res, $next); }); }; return $this; }
php
protected function push(callable $newTopMiddleware) { $oldStack = $this->middlewareStack; if ($oldStack === null) { $this->middlewareStack = $newTopMiddleware; return $this; } $this->middlewareStack = function ($request, $response, callable $next) use ($oldStack, $newTopMiddleware) { return $newTopMiddleware($request, $response, function ($req, $res) use ($next, $oldStack) { return $oldStack($req, $res, $next); }); }; return $this; }
[ "protected", "function", "push", "(", "callable", "$", "newTopMiddleware", ")", "{", "$", "oldStack", "=", "$", "this", "->", "middlewareStack", ";", "if", "(", "$", "oldStack", "===", "null", ")", "{", "$", "this", "->", "middlewareStack", "=", "$", "newTopMiddleware", ";", "return", "$", "this", ";", "}", "$", "this", "->", "middlewareStack", "=", "function", "(", "$", "request", ",", "$", "response", ",", "callable", "$", "next", ")", "use", "(", "$", "oldStack", ",", "$", "newTopMiddleware", ")", "{", "return", "$", "newTopMiddleware", "(", "$", "request", ",", "$", "response", ",", "function", "(", "$", "req", ",", "$", "res", ")", "use", "(", "$", "next", ",", "$", "oldStack", ")", "{", "return", "$", "oldStack", "(", "$", "req", ",", "$", "res", ",", "$", "next", ")", ";", "}", ")", ";", "}", ";", "return", "$", "this", ";", "}" ]
Push a middleware onto the top of this stack. @param callable $newTopMiddleware the middleware to be pushed onto the top. @return static $this
[ "Push", "a", "middleware", "onto", "the", "top", "of", "this", "stack", "." ]
e62da0bf1dae2c92014e254baef0c8b7e8c342e6
https://github.com/schnittstabil/psr7-middleware-stack/blob/e62da0bf1dae2c92014e254baef0c8b7e8c342e6/src/MiddlewareStackTrait.php#L19-L36
7,127
phlexible/phlexible
src/Phlexible/Bundle/UserBundle/Controller/GroupsController.php
GroupsController.listAction
public function listAction() { $groupManager = $this->get('phlexible_user.group_manager'); $groups = []; foreach ($groupManager->findAll() as $group) { $members = []; foreach ($group->getUsers() as $user) { $members[] = $user->getDisplayName(); } sort($members); $groups[] = [ 'gid' => $group->getId(), 'name' => $group->getName(), 'readonly' => false, 'memberCnt' => count($members), 'members' => $members, ]; } return new JsonResponse($groups); }
php
public function listAction() { $groupManager = $this->get('phlexible_user.group_manager'); $groups = []; foreach ($groupManager->findAll() as $group) { $members = []; foreach ($group->getUsers() as $user) { $members[] = $user->getDisplayName(); } sort($members); $groups[] = [ 'gid' => $group->getId(), 'name' => $group->getName(), 'readonly' => false, 'memberCnt' => count($members), 'members' => $members, ]; } return new JsonResponse($groups); }
[ "public", "function", "listAction", "(", ")", "{", "$", "groupManager", "=", "$", "this", "->", "get", "(", "'phlexible_user.group_manager'", ")", ";", "$", "groups", "=", "[", "]", ";", "foreach", "(", "$", "groupManager", "->", "findAll", "(", ")", "as", "$", "group", ")", "{", "$", "members", "=", "[", "]", ";", "foreach", "(", "$", "group", "->", "getUsers", "(", ")", "as", "$", "user", ")", "{", "$", "members", "[", "]", "=", "$", "user", "->", "getDisplayName", "(", ")", ";", "}", "sort", "(", "$", "members", ")", ";", "$", "groups", "[", "]", "=", "[", "'gid'", "=>", "$", "group", "->", "getId", "(", ")", ",", "'name'", "=>", "$", "group", "->", "getName", "(", ")", ",", "'readonly'", "=>", "false", ",", "'memberCnt'", "=>", "count", "(", "$", "members", ")", ",", "'members'", "=>", "$", "members", ",", "]", ";", "}", "return", "new", "JsonResponse", "(", "$", "groups", ")", ";", "}" ]
List groups. @return JsonResponse @Route("", name="users_groups_list") @Method("GET") @ApiDoc( description="Returns a list of groups" )
[ "List", "groups", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/UserBundle/Controller/GroupsController.php#L43-L65
7,128
phlexible/phlexible
src/Phlexible/Bundle/UserBundle/Controller/GroupsController.php
GroupsController.createAction
public function createAction(Request $request) { $name = $request->get('name'); $groupManager = $this->get('phlexible_user.group_manager'); $group = $groupManager->create() ->setName($name) ->setCreateUserId($this->getUser()->getId()) ->setCreatedAt(new \DateTime()) ->setModifyUserId($this->getUser()->getId()) ->setModifiedAt(new \DateTime()); $groupManager->updateGroup($group); $this->get('phlexible_message.message_poster') ->post(UsersMessage::create('Group "'.$group->getName().'" created.')); return new ResultResponse(true, "Group $name created."); }
php
public function createAction(Request $request) { $name = $request->get('name'); $groupManager = $this->get('phlexible_user.group_manager'); $group = $groupManager->create() ->setName($name) ->setCreateUserId($this->getUser()->getId()) ->setCreatedAt(new \DateTime()) ->setModifyUserId($this->getUser()->getId()) ->setModifiedAt(new \DateTime()); $groupManager->updateGroup($group); $this->get('phlexible_message.message_poster') ->post(UsersMessage::create('Group "'.$group->getName().'" created.')); return new ResultResponse(true, "Group $name created."); }
[ "public", "function", "createAction", "(", "Request", "$", "request", ")", "{", "$", "name", "=", "$", "request", "->", "get", "(", "'name'", ")", ";", "$", "groupManager", "=", "$", "this", "->", "get", "(", "'phlexible_user.group_manager'", ")", ";", "$", "group", "=", "$", "groupManager", "->", "create", "(", ")", "->", "setName", "(", "$", "name", ")", "->", "setCreateUserId", "(", "$", "this", "->", "getUser", "(", ")", "->", "getId", "(", ")", ")", "->", "setCreatedAt", "(", "new", "\\", "DateTime", "(", ")", ")", "->", "setModifyUserId", "(", "$", "this", "->", "getUser", "(", ")", "->", "getId", "(", ")", ")", "->", "setModifiedAt", "(", "new", "\\", "DateTime", "(", ")", ")", ";", "$", "groupManager", "->", "updateGroup", "(", "$", "group", ")", ";", "$", "this", "->", "get", "(", "'phlexible_message.message_poster'", ")", "->", "post", "(", "UsersMessage", "::", "create", "(", "'Group \"'", ".", "$", "group", "->", "getName", "(", ")", ".", "'\" created.'", ")", ")", ";", "return", "new", "ResultResponse", "(", "true", ",", "\"Group $name created.\"", ")", ";", "}" ]
Create new group. @param Request $request @return JsonResponse @Route("", name="users_groups_create") @Method("POST") @ApiDoc( description="Create new group", requirements={ {"name"="name", "dataType"="string", "required"=true, "description"="New group name"} } )
[ "Create", "new", "group", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/UserBundle/Controller/GroupsController.php#L82-L101
7,129
phlexible/phlexible
src/Phlexible/Bundle/UserBundle/Controller/GroupsController.php
GroupsController.renameAction
public function renameAction(Request $request, $groupId) { $name = $request->get('name'); $groupManager = $this->get('phlexible_user.group_manager'); $group = $groupManager->find($groupId); $oldName = $group->getName(); $group ->setName($name) ->setModifyUserId($this->getUser()->getId()) ->setModifiedAt(new \DateTime()); $groupManager->updateGroup($group); $this->get('phlexible_message.message_poster') ->post(UsersMessage::create('Group "'.$group->getName().'" updated.')); return new ResultResponse(true, "Group $oldName renamed to $name."); }
php
public function renameAction(Request $request, $groupId) { $name = $request->get('name'); $groupManager = $this->get('phlexible_user.group_manager'); $group = $groupManager->find($groupId); $oldName = $group->getName(); $group ->setName($name) ->setModifyUserId($this->getUser()->getId()) ->setModifiedAt(new \DateTime()); $groupManager->updateGroup($group); $this->get('phlexible_message.message_poster') ->post(UsersMessage::create('Group "'.$group->getName().'" updated.')); return new ResultResponse(true, "Group $oldName renamed to $name."); }
[ "public", "function", "renameAction", "(", "Request", "$", "request", ",", "$", "groupId", ")", "{", "$", "name", "=", "$", "request", "->", "get", "(", "'name'", ")", ";", "$", "groupManager", "=", "$", "this", "->", "get", "(", "'phlexible_user.group_manager'", ")", ";", "$", "group", "=", "$", "groupManager", "->", "find", "(", "$", "groupId", ")", ";", "$", "oldName", "=", "$", "group", "->", "getName", "(", ")", ";", "$", "group", "->", "setName", "(", "$", "name", ")", "->", "setModifyUserId", "(", "$", "this", "->", "getUser", "(", ")", "->", "getId", "(", ")", ")", "->", "setModifiedAt", "(", "new", "\\", "DateTime", "(", ")", ")", ";", "$", "groupManager", "->", "updateGroup", "(", "$", "group", ")", ";", "$", "this", "->", "get", "(", "'phlexible_message.message_poster'", ")", "->", "post", "(", "UsersMessage", "::", "create", "(", "'Group \"'", ".", "$", "group", "->", "getName", "(", ")", ".", "'\" updated.'", ")", ")", ";", "return", "new", "ResultResponse", "(", "true", ",", "\"Group $oldName renamed to $name.\"", ")", ";", "}" ]
Rename group. @param Request $request @param string $groupId @return JsonResponse @Route("/{groupId}", name="users_groups_rename") @Method("PATCH") @ApiDoc( description="Rename group", requirements={ {"name"="name", "dataType"="string", "required"=true, "description"="Rename name"} } )
[ "Rename", "group", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/UserBundle/Controller/GroupsController.php#L119-L138
7,130
phlexible/phlexible
src/Phlexible/Bundle/UserBundle/Controller/GroupsController.php
GroupsController.deleteAction
public function deleteAction($groupId) { $groupManager = $this->get('phlexible_user.group_manager'); $group = $groupManager->find($groupId); $name = $group->getName(); $groupManager->deleteGroup($group); $this->get('phlexible_message.message_poster') ->post(UsersMessage::create('Group "'.$group->getName().'" deleted.')); return new ResultResponse(true, "Group $name deleted."); }
php
public function deleteAction($groupId) { $groupManager = $this->get('phlexible_user.group_manager'); $group = $groupManager->find($groupId); $name = $group->getName(); $groupManager->deleteGroup($group); $this->get('phlexible_message.message_poster') ->post(UsersMessage::create('Group "'.$group->getName().'" deleted.')); return new ResultResponse(true, "Group $name deleted."); }
[ "public", "function", "deleteAction", "(", "$", "groupId", ")", "{", "$", "groupManager", "=", "$", "this", "->", "get", "(", "'phlexible_user.group_manager'", ")", ";", "$", "group", "=", "$", "groupManager", "->", "find", "(", "$", "groupId", ")", ";", "$", "name", "=", "$", "group", "->", "getName", "(", ")", ";", "$", "groupManager", "->", "deleteGroup", "(", "$", "group", ")", ";", "$", "this", "->", "get", "(", "'phlexible_message.message_poster'", ")", "->", "post", "(", "UsersMessage", "::", "create", "(", "'Group \"'", ".", "$", "group", "->", "getName", "(", ")", ".", "'\" deleted.'", ")", ")", ";", "return", "new", "ResultResponse", "(", "true", ",", "\"Group $name deleted.\"", ")", ";", "}" ]
Delete group. @param string $groupId @return JsonResponse @Route("/{groupId}", name="users_groups_delete") @Method("DELETE") @ApiDoc( description="Delete group" )
[ "Delete", "group", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/UserBundle/Controller/GroupsController.php#L152-L165
7,131
agalbourdin/agl-core
src/Db/Query/Count/CountAbstract.php
CountAbstract.setField
public function setField($pField, $pDistinct = false) { Agl::validateParams(array( 'String' => $pField, 'Bool' => $pDistinct )); $this->_field = array( static::FIELD_NAME => $pField, static::FIELD_DISTINCT => $pDistinct ); return $this; }
php
public function setField($pField, $pDistinct = false) { Agl::validateParams(array( 'String' => $pField, 'Bool' => $pDistinct )); $this->_field = array( static::FIELD_NAME => $pField, static::FIELD_DISTINCT => $pDistinct ); return $this; }
[ "public", "function", "setField", "(", "$", "pField", ",", "$", "pDistinct", "=", "false", ")", "{", "Agl", "::", "validateParams", "(", "array", "(", "'String'", "=>", "$", "pField", ",", "'Bool'", "=>", "$", "pDistinct", ")", ")", ";", "$", "this", "->", "_field", "=", "array", "(", "static", "::", "FIELD_NAME", "=>", "$", "pField", ",", "static", "::", "FIELD_DISTINCT", "=>", "$", "pDistinct", ")", ";", "return", "$", "this", ";", "}" ]
Set the main field of the count query. @param array $pField Field name @param bool $pDistinct Don't count duplicated fields @return InsertAbstract
[ "Set", "the", "main", "field", "of", "the", "count", "query", "." ]
1db556f9a49488aa9fab6887fefb7141a79ad97d
https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Db/Query/Count/CountAbstract.php#L75-L87
7,132
laasti/application
src/Http/Application.php
Application.run
public function run(RequestInterface $request = null, ResponseInterface $response = null) { if (is_null($request)) { if (!$this->getContainer()->has('request')) { if ($this->getContainer()->has('Psr\Http\Message\ServerRequestInterface')) { $this->getContainer()->add('request', 'Psr\Http\Message\ServerRequestInterface'); } else if ($this->getContainer()->has('Psr\Http\Message\RequestInterface')) { $this->getContainer()->add('request', 'Psr\Http\Message\RequestInterface'); } } $request = $this->getContainer()->get('request'); } if (is_null($response)) { if (!$this->getContainer()->has('response') && $this->getContainer()->has('Psr\Http\Message\ResponseInterface')) { $this->getContainer()->add('response', 'Psr\Http\Message\ResponseInterface'); } $response = $this->getContainer()->get('response'); } $this->getContainer()->add('request', $request); $this->getContainer()->add('response', $response); $this->setErrorHandler(); $this->getKernel()->run($request, $response); if ($this->getLogger()) { if ($request instanceof ServerRequestInterface) { $this->getLogger()->debug('Script execution time: '.number_format(microtime(true) - $request->getServerParams()['REQUEST_TIME_FLOAT'], 3).' s'); } $this->getLogger()->debug('Memory usage: '.number_format(memory_get_usage()/1024/1024, 3).' MB.'); } }
php
public function run(RequestInterface $request = null, ResponseInterface $response = null) { if (is_null($request)) { if (!$this->getContainer()->has('request')) { if ($this->getContainer()->has('Psr\Http\Message\ServerRequestInterface')) { $this->getContainer()->add('request', 'Psr\Http\Message\ServerRequestInterface'); } else if ($this->getContainer()->has('Psr\Http\Message\RequestInterface')) { $this->getContainer()->add('request', 'Psr\Http\Message\RequestInterface'); } } $request = $this->getContainer()->get('request'); } if (is_null($response)) { if (!$this->getContainer()->has('response') && $this->getContainer()->has('Psr\Http\Message\ResponseInterface')) { $this->getContainer()->add('response', 'Psr\Http\Message\ResponseInterface'); } $response = $this->getContainer()->get('response'); } $this->getContainer()->add('request', $request); $this->getContainer()->add('response', $response); $this->setErrorHandler(); $this->getKernel()->run($request, $response); if ($this->getLogger()) { if ($request instanceof ServerRequestInterface) { $this->getLogger()->debug('Script execution time: '.number_format(microtime(true) - $request->getServerParams()['REQUEST_TIME_FLOAT'], 3).' s'); } $this->getLogger()->debug('Memory usage: '.number_format(memory_get_usage()/1024/1024, 3).' MB.'); } }
[ "public", "function", "run", "(", "RequestInterface", "$", "request", "=", "null", ",", "ResponseInterface", "$", "response", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "request", ")", ")", "{", "if", "(", "!", "$", "this", "->", "getContainer", "(", ")", "->", "has", "(", "'request'", ")", ")", "{", "if", "(", "$", "this", "->", "getContainer", "(", ")", "->", "has", "(", "'Psr\\Http\\Message\\ServerRequestInterface'", ")", ")", "{", "$", "this", "->", "getContainer", "(", ")", "->", "add", "(", "'request'", ",", "'Psr\\Http\\Message\\ServerRequestInterface'", ")", ";", "}", "else", "if", "(", "$", "this", "->", "getContainer", "(", ")", "->", "has", "(", "'Psr\\Http\\Message\\RequestInterface'", ")", ")", "{", "$", "this", "->", "getContainer", "(", ")", "->", "add", "(", "'request'", ",", "'Psr\\Http\\Message\\RequestInterface'", ")", ";", "}", "}", "$", "request", "=", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'request'", ")", ";", "}", "if", "(", "is_null", "(", "$", "response", ")", ")", "{", "if", "(", "!", "$", "this", "->", "getContainer", "(", ")", "->", "has", "(", "'response'", ")", "&&", "$", "this", "->", "getContainer", "(", ")", "->", "has", "(", "'Psr\\Http\\Message\\ResponseInterface'", ")", ")", "{", "$", "this", "->", "getContainer", "(", ")", "->", "add", "(", "'response'", ",", "'Psr\\Http\\Message\\ResponseInterface'", ")", ";", "}", "$", "response", "=", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'response'", ")", ";", "}", "$", "this", "->", "getContainer", "(", ")", "->", "add", "(", "'request'", ",", "$", "request", ")", ";", "$", "this", "->", "getContainer", "(", ")", "->", "add", "(", "'response'", ",", "$", "response", ")", ";", "$", "this", "->", "setErrorHandler", "(", ")", ";", "$", "this", "->", "getKernel", "(", ")", "->", "run", "(", "$", "request", ",", "$", "response", ")", ";", "if", "(", "$", "this", "->", "getLogger", "(", ")", ")", "{", "if", "(", "$", "request", "instanceof", "ServerRequestInterface", ")", "{", "$", "this", "->", "getLogger", "(", ")", "->", "debug", "(", "'Script execution time: '", ".", "number_format", "(", "microtime", "(", "true", ")", "-", "$", "request", "->", "getServerParams", "(", ")", "[", "'REQUEST_TIME_FLOAT'", "]", ",", "3", ")", ".", "' s'", ")", ";", "}", "$", "this", "->", "getLogger", "(", ")", "->", "debug", "(", "'Memory usage: '", ".", "number_format", "(", "memory_get_usage", "(", ")", "/", "1024", "/", "1024", ",", "3", ")", ".", "' MB.'", ")", ";", "}", "}" ]
Handles the request and delivers the response through the stack @param RequestInterface|null $request Request to process @param ResponseInterface|null $response Response to process
[ "Handles", "the", "request", "and", "delivers", "the", "response", "through", "the", "stack" ]
f68b310f3ca189283c22c0f2eabdc7c608721019
https://github.com/laasti/application/blob/f68b310f3ca189283c22c0f2eabdc7c608721019/src/Http/Application.php#L80-L112
7,133
laasti/application
src/Http/Application.php
Application.getLogger
public function getLogger() { if (is_null($this->logger)) { if ($this->getContainer()->has('logger')) { return $this->getContainer()->get('logger'); } else if ($this->getContainer()->has('Psr\Log\LoggerInterface')) { return $this->getContainer()->get('Psr\Log\LoggerInterface'); } else if (class_exists('Monolog\Logger')) { $this->getContainer()->addServiceProvider(new \Laasti\Log\MonologProvider); return $this->getContainer()->get('logger'); } } return $this->logger; }
php
public function getLogger() { if (is_null($this->logger)) { if ($this->getContainer()->has('logger')) { return $this->getContainer()->get('logger'); } else if ($this->getContainer()->has('Psr\Log\LoggerInterface')) { return $this->getContainer()->get('Psr\Log\LoggerInterface'); } else if (class_exists('Monolog\Logger')) { $this->getContainer()->addServiceProvider(new \Laasti\Log\MonologProvider); return $this->getContainer()->get('logger'); } } return $this->logger; }
[ "public", "function", "getLogger", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "logger", ")", ")", "{", "if", "(", "$", "this", "->", "getContainer", "(", ")", "->", "has", "(", "'logger'", ")", ")", "{", "return", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'logger'", ")", ";", "}", "else", "if", "(", "$", "this", "->", "getContainer", "(", ")", "->", "has", "(", "'Psr\\Log\\LoggerInterface'", ")", ")", "{", "return", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'Psr\\Log\\LoggerInterface'", ")", ";", "}", "else", "if", "(", "class_exists", "(", "'Monolog\\Logger'", ")", ")", "{", "$", "this", "->", "getContainer", "(", ")", "->", "addServiceProvider", "(", "new", "\\", "Laasti", "\\", "Log", "\\", "MonologProvider", ")", ";", "return", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'logger'", ")", ";", "}", "}", "return", "$", "this", "->", "logger", ";", "}" ]
Returns application logger @return LoggerInterface
[ "Returns", "application", "logger" ]
f68b310f3ca189283c22c0f2eabdc7c608721019
https://github.com/laasti/application/blob/f68b310f3ca189283c22c0f2eabdc7c608721019/src/Http/Application.php#L118-L133
7,134
fezfez/keep-update
src/KeepUpdate/PropertyDAO.php
PropertyDAO.getSynchronizedProperty
public function getSynchronizedProperty(\JsonSerializable $classInstance, array $data) { $keys = array_keys($classInstance->jsonSerialize()); $sync = array(); // Check if all key are there foreach ($keys as $key) { $camelCaseKey = $this->toCamelCase($key); if (array_key_exists($key, $data) === false) { throw new ValidationException(sprintf('Key "%s" does not exist in "%s"', $key, json_encode($data))); } elseif (property_exists($classInstance, $camelCaseKey) === true) { $sync[] = $camelCaseKey; } } return $sync; }
php
public function getSynchronizedProperty(\JsonSerializable $classInstance, array $data) { $keys = array_keys($classInstance->jsonSerialize()); $sync = array(); // Check if all key are there foreach ($keys as $key) { $camelCaseKey = $this->toCamelCase($key); if (array_key_exists($key, $data) === false) { throw new ValidationException(sprintf('Key "%s" does not exist in "%s"', $key, json_encode($data))); } elseif (property_exists($classInstance, $camelCaseKey) === true) { $sync[] = $camelCaseKey; } } return $sync; }
[ "public", "function", "getSynchronizedProperty", "(", "\\", "JsonSerializable", "$", "classInstance", ",", "array", "$", "data", ")", "{", "$", "keys", "=", "array_keys", "(", "$", "classInstance", "->", "jsonSerialize", "(", ")", ")", ";", "$", "sync", "=", "array", "(", ")", ";", "// Check if all key are there", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "$", "camelCaseKey", "=", "$", "this", "->", "toCamelCase", "(", "$", "key", ")", ";", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "data", ")", "===", "false", ")", "{", "throw", "new", "ValidationException", "(", "sprintf", "(", "'Key \"%s\" does not exist in \"%s\"'", ",", "$", "key", ",", "json_encode", "(", "$", "data", ")", ")", ")", ";", "}", "elseif", "(", "property_exists", "(", "$", "classInstance", ",", "$", "camelCaseKey", ")", "===", "true", ")", "{", "$", "sync", "[", "]", "=", "$", "camelCaseKey", ";", "}", "}", "return", "$", "sync", ";", "}" ]
Retrieve the synchorinized property with return data by jsonSerialize @param JsonSerializable $classInstance @param array $data @return array
[ "Retrieve", "the", "synchorinized", "property", "with", "return", "data", "by", "jsonSerialize" ]
43a6080e8649fbad9e7edf8a18186e81f2cd145d
https://github.com/fezfez/keep-update/blob/43a6080e8649fbad9e7edf8a18186e81f2cd145d/src/KeepUpdate/PropertyDAO.php#L22-L39
7,135
okaufmann/google-movies-client
src/GoogleMoviesClient/Helpers/ParseHelper.php
ParseHelper.getParamFromLink
public static function getParamFromLink($url, $paramName) { if (!$url) { throw new \InvalidArgumentException('url'); } if (!$paramName) { throw new \InvalidArgumentException('paramName'); } $parts = parse_url(html_entity_decode($url)); if (isset($parts)) { parse_str($parts['query'], $query); if (array_key_exists($paramName, $query)) { return $query[$paramName]; } } return null; }
php
public static function getParamFromLink($url, $paramName) { if (!$url) { throw new \InvalidArgumentException('url'); } if (!$paramName) { throw new \InvalidArgumentException('paramName'); } $parts = parse_url(html_entity_decode($url)); if (isset($parts)) { parse_str($parts['query'], $query); if (array_key_exists($paramName, $query)) { return $query[$paramName]; } } return null; }
[ "public", "static", "function", "getParamFromLink", "(", "$", "url", ",", "$", "paramName", ")", "{", "if", "(", "!", "$", "url", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'url'", ")", ";", "}", "if", "(", "!", "$", "paramName", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'paramName'", ")", ";", "}", "$", "parts", "=", "parse_url", "(", "html_entity_decode", "(", "$", "url", ")", ")", ";", "if", "(", "isset", "(", "$", "parts", ")", ")", "{", "parse_str", "(", "$", "parts", "[", "'query'", "]", ",", "$", "query", ")", ";", "if", "(", "array_key_exists", "(", "$", "paramName", ",", "$", "query", ")", ")", "{", "return", "$", "query", "[", "$", "paramName", "]", ";", "}", "}", "return", "null", ";", "}" ]
Get value of a passes param in a query. @param $url @param $paramName @return null
[ "Get", "value", "of", "a", "passes", "param", "in", "a", "query", "." ]
70ad4d3c640016cf24a0fd45ed8509029a6c02c6
https://github.com/okaufmann/google-movies-client/blob/70ad4d3c640016cf24a0fd45ed8509029a6c02c6/src/GoogleMoviesClient/Helpers/ParseHelper.php#L15-L34
7,136
romeOz/rock-template
src/template/Html.php
Html.beginForm
public static function beginForm($action = null, $method = 'post', $name = null, $options = []) { $hiddenInputs = []; $action = (array)$action; if (!isset($url['@scheme'])) { $action['@scheme'] = Url::ABS; } $action = Url::modify($action); $request = Instance::ensure('request', '\rock\request\Request', [], false); if ($request instanceof Request) { if (strcasecmp($method, 'get') && strcasecmp($method, 'post')) { // simulate PUT, DELETE, etc. via POST $hiddenInputs[] = static::hiddenInput( isset($name) ? $name . "[{$request->methodParam}]" : $request->methodParam, $method, ArrayHelper::getValue($options, 'hiddenMethod', []) ); $method = 'post'; } } $csrf = static::getCSRF(); if ($csrf instanceof CSRF && $csrf->enableCsrfValidation && !strcasecmp($method, 'post')) { $token = $csrf->get(); $hiddenInputs[] = static::hiddenInput( isset($name) ? "{$name}[_csrf]" : '_csrf', $token, ArrayHelper::getValue($options, 'hiddenCsrf', []) ); } if (!strcasecmp($method, 'get') && ($pos = strpos($action, '?')) !== false) { // query parameters in the action are ignored for GET method // we use hidden fields to add them back foreach (explode('&', substr($action, $pos + 1)) as $pair) { if (($pos1 = strpos($pair, '=')) !== false) { $hiddenInputs[] = static::hiddenInput( urldecode(substr($pair, 0, $pos1)), urldecode(substr($pair, $pos1 + 1)) ); } else { $hiddenInputs[] = static::hiddenInput(urldecode($pair), ''); } } $action = substr($action, 0, $pos); } unset($options['hiddenMethod'], $options['hiddenCsrf']); $options['action'] = $action; $options['method'] = $method; $form = static::beginTag('form', $options); if (!empty($hiddenInputs)) { $form .= "\n" . implode("\n", $hiddenInputs); } return $form; }
php
public static function beginForm($action = null, $method = 'post', $name = null, $options = []) { $hiddenInputs = []; $action = (array)$action; if (!isset($url['@scheme'])) { $action['@scheme'] = Url::ABS; } $action = Url::modify($action); $request = Instance::ensure('request', '\rock\request\Request', [], false); if ($request instanceof Request) { if (strcasecmp($method, 'get') && strcasecmp($method, 'post')) { // simulate PUT, DELETE, etc. via POST $hiddenInputs[] = static::hiddenInput( isset($name) ? $name . "[{$request->methodParam}]" : $request->methodParam, $method, ArrayHelper::getValue($options, 'hiddenMethod', []) ); $method = 'post'; } } $csrf = static::getCSRF(); if ($csrf instanceof CSRF && $csrf->enableCsrfValidation && !strcasecmp($method, 'post')) { $token = $csrf->get(); $hiddenInputs[] = static::hiddenInput( isset($name) ? "{$name}[_csrf]" : '_csrf', $token, ArrayHelper::getValue($options, 'hiddenCsrf', []) ); } if (!strcasecmp($method, 'get') && ($pos = strpos($action, '?')) !== false) { // query parameters in the action are ignored for GET method // we use hidden fields to add them back foreach (explode('&', substr($action, $pos + 1)) as $pair) { if (($pos1 = strpos($pair, '=')) !== false) { $hiddenInputs[] = static::hiddenInput( urldecode(substr($pair, 0, $pos1)), urldecode(substr($pair, $pos1 + 1)) ); } else { $hiddenInputs[] = static::hiddenInput(urldecode($pair), ''); } } $action = substr($action, 0, $pos); } unset($options['hiddenMethod'], $options['hiddenCsrf']); $options['action'] = $action; $options['method'] = $method; $form = static::beginTag('form', $options); if (!empty($hiddenInputs)) { $form .= "\n" . implode("\n", $hiddenInputs); } return $form; }
[ "public", "static", "function", "beginForm", "(", "$", "action", "=", "null", ",", "$", "method", "=", "'post'", ",", "$", "name", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "$", "hiddenInputs", "=", "[", "]", ";", "$", "action", "=", "(", "array", ")", "$", "action", ";", "if", "(", "!", "isset", "(", "$", "url", "[", "'@scheme'", "]", ")", ")", "{", "$", "action", "[", "'@scheme'", "]", "=", "Url", "::", "ABS", ";", "}", "$", "action", "=", "Url", "::", "modify", "(", "$", "action", ")", ";", "$", "request", "=", "Instance", "::", "ensure", "(", "'request'", ",", "'\\rock\\request\\Request'", ",", "[", "]", ",", "false", ")", ";", "if", "(", "$", "request", "instanceof", "Request", ")", "{", "if", "(", "strcasecmp", "(", "$", "method", ",", "'get'", ")", "&&", "strcasecmp", "(", "$", "method", ",", "'post'", ")", ")", "{", "// simulate PUT, DELETE, etc. via POST", "$", "hiddenInputs", "[", "]", "=", "static", "::", "hiddenInput", "(", "isset", "(", "$", "name", ")", "?", "$", "name", ".", "\"[{$request->methodParam}]\"", ":", "$", "request", "->", "methodParam", ",", "$", "method", ",", "ArrayHelper", "::", "getValue", "(", "$", "options", ",", "'hiddenMethod'", ",", "[", "]", ")", ")", ";", "$", "method", "=", "'post'", ";", "}", "}", "$", "csrf", "=", "static", "::", "getCSRF", "(", ")", ";", "if", "(", "$", "csrf", "instanceof", "CSRF", "&&", "$", "csrf", "->", "enableCsrfValidation", "&&", "!", "strcasecmp", "(", "$", "method", ",", "'post'", ")", ")", "{", "$", "token", "=", "$", "csrf", "->", "get", "(", ")", ";", "$", "hiddenInputs", "[", "]", "=", "static", "::", "hiddenInput", "(", "isset", "(", "$", "name", ")", "?", "\"{$name}[_csrf]\"", ":", "'_csrf'", ",", "$", "token", ",", "ArrayHelper", "::", "getValue", "(", "$", "options", ",", "'hiddenCsrf'", ",", "[", "]", ")", ")", ";", "}", "if", "(", "!", "strcasecmp", "(", "$", "method", ",", "'get'", ")", "&&", "(", "$", "pos", "=", "strpos", "(", "$", "action", ",", "'?'", ")", ")", "!==", "false", ")", "{", "// query parameters in the action are ignored for GET method", "// we use hidden fields to add them back", "foreach", "(", "explode", "(", "'&'", ",", "substr", "(", "$", "action", ",", "$", "pos", "+", "1", ")", ")", "as", "$", "pair", ")", "{", "if", "(", "(", "$", "pos1", "=", "strpos", "(", "$", "pair", ",", "'='", ")", ")", "!==", "false", ")", "{", "$", "hiddenInputs", "[", "]", "=", "static", "::", "hiddenInput", "(", "urldecode", "(", "substr", "(", "$", "pair", ",", "0", ",", "$", "pos1", ")", ")", ",", "urldecode", "(", "substr", "(", "$", "pair", ",", "$", "pos1", "+", "1", ")", ")", ")", ";", "}", "else", "{", "$", "hiddenInputs", "[", "]", "=", "static", "::", "hiddenInput", "(", "urldecode", "(", "$", "pair", ")", ",", "''", ")", ";", "}", "}", "$", "action", "=", "substr", "(", "$", "action", ",", "0", ",", "$", "pos", ")", ";", "}", "unset", "(", "$", "options", "[", "'hiddenMethod'", "]", ",", "$", "options", "[", "'hiddenCsrf'", "]", ")", ";", "$", "options", "[", "'action'", "]", "=", "$", "action", ";", "$", "options", "[", "'method'", "]", "=", "$", "method", ";", "$", "form", "=", "static", "::", "beginTag", "(", "'form'", ",", "$", "options", ")", ";", "if", "(", "!", "empty", "(", "$", "hiddenInputs", ")", ")", "{", "$", "form", ".=", "\"\\n\"", ".", "implode", "(", "\"\\n\"", ",", "$", "hiddenInputs", ")", ";", "}", "return", "$", "form", ";", "}" ]
Generates a form start tag. @param array|string $action the form action URL. This parameter will be processed by {@see \rock\url\Url::getAbsoluteUrl()}. @param string $method the form submission method, such as "post", "get", "put", "delete" (case-insensitive). Since most browsers only support "post" and "get", if other methods are given, they will be simulated using "post", and a hidden input will be added which contains the actual method type. See {@see \rock\request\Request::$methodVar} for more details. @param string|null $name name of form @param array $options the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using {@see \rock\template\Html::encode()}. If a value is null, the corresponding attribute will not be rendered. See {@see \rock\template\Html::renderTagAttributes()} for details on how attributes are being rendered. @return string the generated form start tag. @see endForm()
[ "Generates", "a", "form", "start", "tag", "." ]
fcb7bd6dd923d11f02a1c71a63065f3f49728e92
https://github.com/romeOz/rock-template/blob/fcb7bd6dd923d11f02a1c71a63065f3f49728e92/src/template/Html.php#L312-L367
7,137
romeOz/rock-template
src/template/Html.php
Html.checkbox
public static function checkbox($name, $checked = false, $options = []) { $options['checked'] = (boolean)$checked; $value = array_key_exists('value', $options) ? $options['value'] : '1'; if (isset($options['uncheck'])) { // add a hidden field so that if the checkbox is not selected, it still submits a value $hidden = static::hiddenInput($name, $options['uncheck']); unset($options['uncheck']); } else { $hidden = ''; } if (isset($options['label'])) { $label = $options['label']; $labelOptions = isset($options['labelOptions']) ? $options['labelOptions'] : []; unset($options['label'], $options['labelOptions']); $content = static::label(static::input('checkbox', $name, $value, $options) . ' ' . $label, null, $labelOptions); return $hidden . $content; } else { return $hidden . static::input('checkbox', $name, $value, $options); } }
php
public static function checkbox($name, $checked = false, $options = []) { $options['checked'] = (boolean)$checked; $value = array_key_exists('value', $options) ? $options['value'] : '1'; if (isset($options['uncheck'])) { // add a hidden field so that if the checkbox is not selected, it still submits a value $hidden = static::hiddenInput($name, $options['uncheck']); unset($options['uncheck']); } else { $hidden = ''; } if (isset($options['label'])) { $label = $options['label']; $labelOptions = isset($options['labelOptions']) ? $options['labelOptions'] : []; unset($options['label'], $options['labelOptions']); $content = static::label(static::input('checkbox', $name, $value, $options) . ' ' . $label, null, $labelOptions); return $hidden . $content; } else { return $hidden . static::input('checkbox', $name, $value, $options); } }
[ "public", "static", "function", "checkbox", "(", "$", "name", ",", "$", "checked", "=", "false", ",", "$", "options", "=", "[", "]", ")", "{", "$", "options", "[", "'checked'", "]", "=", "(", "boolean", ")", "$", "checked", ";", "$", "value", "=", "array_key_exists", "(", "'value'", ",", "$", "options", ")", "?", "$", "options", "[", "'value'", "]", ":", "'1'", ";", "if", "(", "isset", "(", "$", "options", "[", "'uncheck'", "]", ")", ")", "{", "// add a hidden field so that if the checkbox is not selected, it still submits a value", "$", "hidden", "=", "static", "::", "hiddenInput", "(", "$", "name", ",", "$", "options", "[", "'uncheck'", "]", ")", ";", "unset", "(", "$", "options", "[", "'uncheck'", "]", ")", ";", "}", "else", "{", "$", "hidden", "=", "''", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'label'", "]", ")", ")", "{", "$", "label", "=", "$", "options", "[", "'label'", "]", ";", "$", "labelOptions", "=", "isset", "(", "$", "options", "[", "'labelOptions'", "]", ")", "?", "$", "options", "[", "'labelOptions'", "]", ":", "[", "]", ";", "unset", "(", "$", "options", "[", "'label'", "]", ",", "$", "options", "[", "'labelOptions'", "]", ")", ";", "$", "content", "=", "static", "::", "label", "(", "static", "::", "input", "(", "'checkbox'", ",", "$", "name", ",", "$", "value", ",", "$", "options", ")", ".", "' '", ".", "$", "label", ",", "null", ",", "$", "labelOptions", ")", ";", "return", "$", "hidden", ".", "$", "content", ";", "}", "else", "{", "return", "$", "hidden", ".", "static", "::", "input", "(", "'checkbox'", ",", "$", "name", ",", "$", "value", ",", "$", "options", ")", ";", "}", "}" ]
Generates a checkbox input. @param string $name the name attribute. @param boolean $checked whether the checkbox should be checked. @param array $options the tag options in terms of name-value pairs. The following options are specially handled: - uncheck: string, the value associated with the uncheck state of the checkbox. When this attribute is present, a hidden input will be generated so that if the checkbox is not checked and is submitted, the value of this attribute will still be submitted to the server via the hidden input. - label: string, a label displayed next to the checkbox. It will NOT be HTML-encoded. Therefore you can pass in HTML code such as an image tag. If this is is coming from end users, you should {@see \rock\template\Html::encode()} it to prevent XSS attacks. When this option is specified, the checkbox will be enclosed by a label tag. - labelOptions: array, the HTML attributes for the label tag. Do not set this option unless you set the "label" option. The rest of the options will be rendered as the attributes of the resulting checkbox tag. The values will be HTML-encoded using {@see \rock\template\Html::encode()} . If a value is null, the corresponding attribute will not be rendered. See {@see \rock\template\Html::renderTagAttributes()} for details on how attributes are being rendered. @return string the generated checkbox tag
[ "Generates", "a", "checkbox", "input", "." ]
fcb7bd6dd923d11f02a1c71a63065f3f49728e92
https://github.com/romeOz/rock-template/blob/fcb7bd6dd923d11f02a1c71a63065f3f49728e92/src/template/Html.php#L769-L789
7,138
romeOz/rock-template
src/template/Html.php
Html.removeCssClass
public static function removeCssClass(&$options, $class) { if (isset($options['class'])) { $classes = array_unique(preg_split('/\s+/', $options['class'] . ' ' . $class, -1, PREG_SPLIT_NO_EMPTY)); if (($index = array_search($class, $classes)) !== false) { unset($classes[$index]); } if (empty($classes)) { unset($options['class']); } else { $options['class'] = implode(' ', $classes); } } }
php
public static function removeCssClass(&$options, $class) { if (isset($options['class'])) { $classes = array_unique(preg_split('/\s+/', $options['class'] . ' ' . $class, -1, PREG_SPLIT_NO_EMPTY)); if (($index = array_search($class, $classes)) !== false) { unset($classes[$index]); } if (empty($classes)) { unset($options['class']); } else { $options['class'] = implode(' ', $classes); } } }
[ "public", "static", "function", "removeCssClass", "(", "&", "$", "options", ",", "$", "class", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "'class'", "]", ")", ")", "{", "$", "classes", "=", "array_unique", "(", "preg_split", "(", "'/\\s+/'", ",", "$", "options", "[", "'class'", "]", ".", "' '", ".", "$", "class", ",", "-", "1", ",", "PREG_SPLIT_NO_EMPTY", ")", ")", ";", "if", "(", "(", "$", "index", "=", "array_search", "(", "$", "class", ",", "$", "classes", ")", ")", "!==", "false", ")", "{", "unset", "(", "$", "classes", "[", "$", "index", "]", ")", ";", "}", "if", "(", "empty", "(", "$", "classes", ")", ")", "{", "unset", "(", "$", "options", "[", "'class'", "]", ")", ";", "}", "else", "{", "$", "options", "[", "'class'", "]", "=", "implode", "(", "' '", ",", "$", "classes", ")", ";", "}", "}", "}" ]
Removes a CSS class from the specified options. @param array $options the options to be modified. @param string $class the CSS class to be removed
[ "Removes", "a", "CSS", "class", "from", "the", "specified", "options", "." ]
fcb7bd6dd923d11f02a1c71a63065f3f49728e92
https://github.com/romeOz/rock-template/blob/fcb7bd6dd923d11f02a1c71a63065f3f49728e92/src/template/Html.php#L1265-L1278
7,139
romeOz/rock-template
src/template/Html.php
Html.addCssStyle
public static function addCssStyle(&$options, $style, $overwrite = true) { if (!empty($options['style'])) { $oldStyle = static::cssStyleToArray($options['style']); $newStyle = is_array($style) ? $style : static::cssStyleToArray($style); if (!$overwrite) { foreach ($newStyle as $property => $value) { if (isset($oldStyle[$property])) { unset($newStyle[$property]); } } } $style = static::cssStyleFromArray(array_merge($oldStyle, $newStyle)); } $options['style'] = $style; }
php
public static function addCssStyle(&$options, $style, $overwrite = true) { if (!empty($options['style'])) { $oldStyle = static::cssStyleToArray($options['style']); $newStyle = is_array($style) ? $style : static::cssStyleToArray($style); if (!$overwrite) { foreach ($newStyle as $property => $value) { if (isset($oldStyle[$property])) { unset($newStyle[$property]); } } } $style = static::cssStyleFromArray(array_merge($oldStyle, $newStyle)); } $options['style'] = $style; }
[ "public", "static", "function", "addCssStyle", "(", "&", "$", "options", ",", "$", "style", ",", "$", "overwrite", "=", "true", ")", "{", "if", "(", "!", "empty", "(", "$", "options", "[", "'style'", "]", ")", ")", "{", "$", "oldStyle", "=", "static", "::", "cssStyleToArray", "(", "$", "options", "[", "'style'", "]", ")", ";", "$", "newStyle", "=", "is_array", "(", "$", "style", ")", "?", "$", "style", ":", "static", "::", "cssStyleToArray", "(", "$", "style", ")", ";", "if", "(", "!", "$", "overwrite", ")", "{", "foreach", "(", "$", "newStyle", "as", "$", "property", "=>", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "oldStyle", "[", "$", "property", "]", ")", ")", "{", "unset", "(", "$", "newStyle", "[", "$", "property", "]", ")", ";", "}", "}", "}", "$", "style", "=", "static", "::", "cssStyleFromArray", "(", "array_merge", "(", "$", "oldStyle", ",", "$", "newStyle", ")", ")", ";", "}", "$", "options", "[", "'style'", "]", "=", "$", "style", ";", "}" ]
Adds the specified CSS style to the HTML options. If the options already contain a `style` element, the new style will be merged with the existing one. If a CSS property exists in both the new and the old styles, the old one may be overwritten if `$overwrite` is true. For example, ```php Html::addCssStyle($options, 'width: 100px; height: 200px'); ``` @param array $options the HTML options to be modified. @param string|array $style the new style string (e.g. `'width: 100px; height: 200px'`) or array (e.g. `['width' => '100px', 'height' => '200px']`). @param boolean $overwrite whether to overwrite existing CSS properties if the new style contain them too. @see removeCssStyle() @see cssStyleFromArray() @see cssStyleToArray()
[ "Adds", "the", "specified", "CSS", "style", "to", "the", "HTML", "options", "." ]
fcb7bd6dd923d11f02a1c71a63065f3f49728e92
https://github.com/romeOz/rock-template/blob/fcb7bd6dd923d11f02a1c71a63065f3f49728e92/src/template/Html.php#L1302-L1317
7,140
romeOz/rock-template
src/template/Html.php
Html.removeCssStyle
public static function removeCssStyle(&$options, $properties) { if (!empty($options['style'])) { $style = static::cssStyleToArray($options['style']); foreach ((array)$properties as $property) { unset($style[$property]); } $options['style'] = static::cssStyleFromArray($style); } }
php
public static function removeCssStyle(&$options, $properties) { if (!empty($options['style'])) { $style = static::cssStyleToArray($options['style']); foreach ((array)$properties as $property) { unset($style[$property]); } $options['style'] = static::cssStyleFromArray($style); } }
[ "public", "static", "function", "removeCssStyle", "(", "&", "$", "options", ",", "$", "properties", ")", "{", "if", "(", "!", "empty", "(", "$", "options", "[", "'style'", "]", ")", ")", "{", "$", "style", "=", "static", "::", "cssStyleToArray", "(", "$", "options", "[", "'style'", "]", ")", ";", "foreach", "(", "(", "array", ")", "$", "properties", "as", "$", "property", ")", "{", "unset", "(", "$", "style", "[", "$", "property", "]", ")", ";", "}", "$", "options", "[", "'style'", "]", "=", "static", "::", "cssStyleFromArray", "(", "$", "style", ")", ";", "}", "}" ]
Removes the specified CSS style from the HTML options. For example, ```php Html::removeCssStyle($options, ['width', 'height']); ``` @param array $options the HTML options to be modified. @param string|array $properties the CSS properties to be removed. You may use a string if you are removing a single property. @see addCssStyle()
[ "Removes", "the", "specified", "CSS", "style", "from", "the", "HTML", "options", "." ]
fcb7bd6dd923d11f02a1c71a63065f3f49728e92
https://github.com/romeOz/rock-template/blob/fcb7bd6dd923d11f02a1c71a63065f3f49728e92/src/template/Html.php#L1333-L1342
7,141
romeOz/rock-template
src/template/Html.php
Html.fromArray
public static function fromArray(array $data) { $result = ''; foreach ($data as $name => $value) { $value = StringHelper::toString($value, "'", Serialize::SERIALIZE_JSON); $result .= "$name=$value; "; } return $result === '' ? null : rtrim($result); }
php
public static function fromArray(array $data) { $result = ''; foreach ($data as $name => $value) { $value = StringHelper::toString($value, "'", Serialize::SERIALIZE_JSON); $result .= "$name=$value; "; } return $result === '' ? null : rtrim($result); }
[ "public", "static", "function", "fromArray", "(", "array", "$", "data", ")", "{", "$", "result", "=", "''", ";", "foreach", "(", "$", "data", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "value", "=", "StringHelper", "::", "toString", "(", "$", "value", ",", "\"'\"", ",", "Serialize", "::", "SERIALIZE_JSON", ")", ";", "$", "result", ".=", "\"$name=$value; \"", ";", "}", "return", "$", "result", "===", "''", "?", "null", ":", "rtrim", "(", "$", "result", ")", ";", "}" ]
Converts a array into a string representation. For example, ```php print_r(Html::fromArray(['width' => '100px', 'height' => '200px'])); // will display: 'width=100px; height=200px;' ``` @param array $data list data @return string
[ "Converts", "a", "array", "into", "a", "string", "representation", "." ]
fcb7bd6dd923d11f02a1c71a63065f3f49728e92
https://github.com/romeOz/rock-template/blob/fcb7bd6dd923d11f02a1c71a63065f3f49728e92/src/template/Html.php#L1357-L1366
7,142
lemonphp/cli
src/App.php
App.boot
protected function boot() { if ($this->booted) { return; } $this->booted = true; foreach ($this->eventSubscribers as $subscriber) { $this->container['eventDispatcher']->addSubscriber($subscriber); } }
php
protected function boot() { if ($this->booted) { return; } $this->booted = true; foreach ($this->eventSubscribers as $subscriber) { $this->container['eventDispatcher']->addSubscriber($subscriber); } }
[ "protected", "function", "boot", "(", ")", "{", "if", "(", "$", "this", "->", "booted", ")", "{", "return", ";", "}", "$", "this", "->", "booted", "=", "true", ";", "foreach", "(", "$", "this", "->", "eventSubscribers", "as", "$", "subscriber", ")", "{", "$", "this", "->", "container", "[", "'eventDispatcher'", "]", "->", "addSubscriber", "(", "$", "subscriber", ")", ";", "}", "}" ]
Boots the Application by calling boot on every provider added and then subscribe in order to add listeners. @return void
[ "Boots", "the", "Application", "by", "calling", "boot", "on", "every", "provider", "added", "and", "then", "subscribe", "in", "order", "to", "add", "listeners", "." ]
55b11789621f106ba33f6f6dec88d12ad953b625
https://github.com/lemonphp/cli/blob/55b11789621f106ba33f6f6dec88d12ad953b625/src/App.php#L105-L115
7,143
lemonphp/cli
src/App.php
App.run
public function run(InputInterface $input = null, OutputInterface $output = null) { $this->boot(); return $this->container['console']->run($input, $output); }
php
public function run(InputInterface $input = null, OutputInterface $output = null) { $this->boot(); return $this->container['console']->run($input, $output); }
[ "public", "function", "run", "(", "InputInterface", "$", "input", "=", "null", ",", "OutputInterface", "$", "output", "=", "null", ")", "{", "$", "this", "->", "boot", "(", ")", ";", "return", "$", "this", "->", "container", "[", "'console'", "]", "->", "run", "(", "$", "input", ",", "$", "output", ")", ";", "}" ]
Executes this application @param \Symfony\Component\Console\Input\InputInterface|null $input @param \Symfony\Component\Console\Output\OutputInterface|null $output @return int
[ "Executes", "this", "application" ]
55b11789621f106ba33f6f6dec88d12ad953b625
https://github.com/lemonphp/cli/blob/55b11789621f106ba33f6f6dec88d12ad953b625/src/App.php#L124-L129
7,144
diatem-net/jin-com
src/Com/WebService/WSClient.php
WSClient.service
public function service($fonction, $listArgument = array()) { try { return $this->client->__soapCall($fonction, $listArgument); } catch (\Exception $e) { throw new \Exception('Erreur lors de l\'appel de la méthode ' . $fonction . ' du webservice : ' . $e->getMessage()); return null; } }
php
public function service($fonction, $listArgument = array()) { try { return $this->client->__soapCall($fonction, $listArgument); } catch (\Exception $e) { throw new \Exception('Erreur lors de l\'appel de la méthode ' . $fonction . ' du webservice : ' . $e->getMessage()); return null; } }
[ "public", "function", "service", "(", "$", "fonction", ",", "$", "listArgument", "=", "array", "(", ")", ")", "{", "try", "{", "return", "$", "this", "->", "client", "->", "__soapCall", "(", "$", "fonction", ",", "$", "listArgument", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "\\", "Exception", "(", "'Erreur lors de l\\'appel de la méthode ' ", " ", "f", "onction ", " ", " du webservice : ' ", " ", "e", "-", ">g", "etMessage(", ")", ")", ";", "\r", "return", "null", ";", "}", "}" ]
Permet d'appeler une fonction du webservice @param string $fonction Fonction du webservice à utiliser @param array $listArgument Tableau associatifs d'arguments pour la fonction (cle => valeur) @return object Renvoie le résultat de la fonction du webservice utilisée
[ "Permet", "d", "appeler", "une", "fonction", "du", "webservice" ]
7449f555676cc058130377d74c845ff91b6b286f
https://github.com/diatem-net/jin-com/blob/7449f555676cc058130377d74c845ff91b6b286f/src/Com/WebService/WSClient.php#L44-L52
7,145
mvlabs/MvlabsLumber
src/MvlabsLumber/Service/Logger.php
Logger.getChannel
public function getChannel($s_channelName) { if (!array_key_exists($s_channelName, $this->aI_channels)) { throw new \UnexpectedValueException('Channel ' . $s_channelName . ' does not exist'); } return $this->aI_channels[$s_channelName]; }
php
public function getChannel($s_channelName) { if (!array_key_exists($s_channelName, $this->aI_channels)) { throw new \UnexpectedValueException('Channel ' . $s_channelName . ' does not exist'); } return $this->aI_channels[$s_channelName]; }
[ "public", "function", "getChannel", "(", "$", "s_channelName", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "s_channelName", ",", "$", "this", "->", "aI_channels", ")", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "'Channel '", ".", "$", "s_channelName", ".", "' does not exist'", ")", ";", "}", "return", "$", "this", "->", "aI_channels", "[", "$", "s_channelName", "]", ";", "}" ]
Gets a spcific channel @param string $s_channelName Channel name
[ "Gets", "a", "spcific", "channel" ]
b9491b5b6f3a68ed18018408243cdd594424c5e2
https://github.com/mvlabs/MvlabsLumber/blob/b9491b5b6f3a68ed18018408243cdd594424c5e2/src/MvlabsLumber/Service/Logger.php#L126-L133
7,146
mvlabs/MvlabsLumber
src/MvlabsLumber/Service/Logger.php
Logger.removeChannel
public function removeChannel($s_channelName) { if (!array_key_exists($s_channelName, $this->aI_channels)) { throw new \UnexpectedValueException('Channel ' . $s_channelName . ' does not exist. Cannot remove it'); } unset($this->aI_channels[$s_channelName]); }
php
public function removeChannel($s_channelName) { if (!array_key_exists($s_channelName, $this->aI_channels)) { throw new \UnexpectedValueException('Channel ' . $s_channelName . ' does not exist. Cannot remove it'); } unset($this->aI_channels[$s_channelName]); }
[ "public", "function", "removeChannel", "(", "$", "s_channelName", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "s_channelName", ",", "$", "this", "->", "aI_channels", ")", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "'Channel '", ".", "$", "s_channelName", ".", "' does not exist. Cannot remove it'", ")", ";", "}", "unset", "(", "$", "this", "->", "aI_channels", "[", "$", "s_channelName", "]", ")", ";", "}" ]
Removes a channel from list of registered ones @param string $s_channelName Channel name
[ "Removes", "a", "channel", "from", "list", "of", "registered", "ones" ]
b9491b5b6f3a68ed18018408243cdd594424c5e2
https://github.com/mvlabs/MvlabsLumber/blob/b9491b5b6f3a68ed18018408243cdd594424c5e2/src/MvlabsLumber/Service/Logger.php#L141-L148
7,147
mvlabs/MvlabsLumber
src/MvlabsLumber/Service/Logger.php
Logger.log
public function log($s_message, $s_level = 'notice', array $am_context = array()) { if (!$this->isValidSeverityLevel($s_level)) { throw new \OutOfRangeException('Severity level ' . $s_level . ' is invalid and can not be used'); } foreach ($this->aI_channels as $s_channelName => $I_channel) { $I_channel->addRecord(self::$as_monologLevels[$s_level], $s_message, $am_context); } }
php
public function log($s_message, $s_level = 'notice', array $am_context = array()) { if (!$this->isValidSeverityLevel($s_level)) { throw new \OutOfRangeException('Severity level ' . $s_level . ' is invalid and can not be used'); } foreach ($this->aI_channels as $s_channelName => $I_channel) { $I_channel->addRecord(self::$as_monologLevels[$s_level], $s_message, $am_context); } }
[ "public", "function", "log", "(", "$", "s_message", ",", "$", "s_level", "=", "'notice'", ",", "array", "$", "am_context", "=", "array", "(", ")", ")", "{", "if", "(", "!", "$", "this", "->", "isValidSeverityLevel", "(", "$", "s_level", ")", ")", "{", "throw", "new", "\\", "OutOfRangeException", "(", "'Severity level '", ".", "$", "s_level", ".", "' is invalid and can not be used'", ")", ";", "}", "foreach", "(", "$", "this", "->", "aI_channels", "as", "$", "s_channelName", "=>", "$", "I_channel", ")", "{", "$", "I_channel", "->", "addRecord", "(", "self", "::", "$", "as_monologLevels", "[", "$", "s_level", "]", ",", "$", "s_message", ",", "$", "am_context", ")", ";", "}", "}" ]
Logs with severity level to all registered channels @param string $s_message Main message content @param mixed $s_level Message severity level. Default is null, which will result in info, as commonly found in logger implementations @param array $am_context Message context - IE Additional information @return null
[ "Logs", "with", "severity", "level", "to", "all", "registered", "channels" ]
b9491b5b6f3a68ed18018408243cdd594424c5e2
https://github.com/mvlabs/MvlabsLumber/blob/b9491b5b6f3a68ed18018408243cdd594424c5e2/src/MvlabsLumber/Service/Logger.php#L159-L169
7,148
face-orm/face
lib/Face/DiORM.php
DiORM.select
public function select(Sql\Query\FQuery $fQuery, $useGlobalInstanceKeeper = false) { $statement=$fQuery->execute($this->config->getPdo()); if($useGlobalInstanceKeeper){ $instanceKeeper = $this->instancesKeeper; }else{ $instanceKeeper = new InstancesKeeper(); } if (!$statement->rowCount()) { return new ResultSet($fQuery->getBaseFace(), $instanceKeeper); } $hydrator = new ArrayHydrator(); $rs = $hydrator->hydrate($fQuery, $statement); return $rs; }
php
public function select(Sql\Query\FQuery $fQuery, $useGlobalInstanceKeeper = false) { $statement=$fQuery->execute($this->config->getPdo()); if($useGlobalInstanceKeeper){ $instanceKeeper = $this->instancesKeeper; }else{ $instanceKeeper = new InstancesKeeper(); } if (!$statement->rowCount()) { return new ResultSet($fQuery->getBaseFace(), $instanceKeeper); } $hydrator = new ArrayHydrator(); $rs = $hydrator->hydrate($fQuery, $statement); return $rs; }
[ "public", "function", "select", "(", "Sql", "\\", "Query", "\\", "FQuery", "$", "fQuery", ",", "$", "useGlobalInstanceKeeper", "=", "false", ")", "{", "$", "statement", "=", "$", "fQuery", "->", "execute", "(", "$", "this", "->", "config", "->", "getPdo", "(", ")", ")", ";", "if", "(", "$", "useGlobalInstanceKeeper", ")", "{", "$", "instanceKeeper", "=", "$", "this", "->", "instancesKeeper", ";", "}", "else", "{", "$", "instanceKeeper", "=", "new", "InstancesKeeper", "(", ")", ";", "}", "if", "(", "!", "$", "statement", "->", "rowCount", "(", ")", ")", "{", "return", "new", "ResultSet", "(", "$", "fQuery", "->", "getBaseFace", "(", ")", ",", "$", "instanceKeeper", ")", ";", "}", "$", "hydrator", "=", "new", "ArrayHydrator", "(", ")", ";", "$", "rs", "=", "$", "hydrator", "->", "hydrate", "(", "$", "fQuery", ",", "$", "statement", ")", ";", "return", "$", "rs", ";", "}" ]
Execute a select query, parse the result and returns a resultSet @param \Face\Sql\Query\FQuery $fQuery @return Sql\Result\ResultSet
[ "Execute", "a", "select", "query", "parse", "the", "result", "and", "returns", "a", "resultSet" ]
85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428
https://github.com/face-orm/face/blob/85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428/lib/Face/DiORM.php#L84-L101
7,149
face-orm/face
lib/Face/DiORM.php
DiORM.simpleInsert
public function simpleInsert($entity){ $simpleInsert = new SimpleInsert($entity,$this->getConfig()); return $this->insert($simpleInsert); }
php
public function simpleInsert($entity){ $simpleInsert = new SimpleInsert($entity,$this->getConfig()); return $this->insert($simpleInsert); }
[ "public", "function", "simpleInsert", "(", "$", "entity", ")", "{", "$", "simpleInsert", "=", "new", "SimpleInsert", "(", "$", "entity", ",", "$", "this", "->", "getConfig", "(", ")", ")", ";", "return", "$", "this", "->", "insert", "(", "$", "simpleInsert", ")", ";", "}" ]
performs a SimpleInsert query for the given entity @param $entity @return InsertResult
[ "performs", "a", "SimpleInsert", "query", "for", "the", "given", "entity" ]
85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428
https://github.com/face-orm/face/blob/85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428/lib/Face/DiORM.php#L119-L122
7,150
face-orm/face
lib/Face/DiORM.php
DiORM.simpleUpdate
public function simpleUpdate($entity){ $simpleUpdate = new SimpleUpdate($entity,$this->getConfig()); return $this->update($simpleUpdate); }
php
public function simpleUpdate($entity){ $simpleUpdate = new SimpleUpdate($entity,$this->getConfig()); return $this->update($simpleUpdate); }
[ "public", "function", "simpleUpdate", "(", "$", "entity", ")", "{", "$", "simpleUpdate", "=", "new", "SimpleUpdate", "(", "$", "entity", ",", "$", "this", "->", "getConfig", "(", ")", ")", ";", "return", "$", "this", "->", "update", "(", "$", "simpleUpdate", ")", ";", "}" ]
performs a SimpleUpdate query for the given entity @param $entity @return UpdateResult
[ "performs", "a", "SimpleUpdate", "query", "for", "the", "given", "entity" ]
85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428
https://github.com/face-orm/face/blob/85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428/lib/Face/DiORM.php#L140-L143
7,151
face-orm/face
lib/Face/DiORM.php
DiORM.simpleDelete
public function simpleDelete($entity){ $simpleDelete = new SimpleDelete($entity,$this->getConfig()); return $this->delete($simpleDelete); }
php
public function simpleDelete($entity){ $simpleDelete = new SimpleDelete($entity,$this->getConfig()); return $this->delete($simpleDelete); }
[ "public", "function", "simpleDelete", "(", "$", "entity", ")", "{", "$", "simpleDelete", "=", "new", "SimpleDelete", "(", "$", "entity", ",", "$", "this", "->", "getConfig", "(", ")", ")", ";", "return", "$", "this", "->", "delete", "(", "$", "simpleDelete", ")", ";", "}" ]
performs a SimpleDelete query for the given entity @param $entity @return DeleteResult
[ "performs", "a", "SimpleDelete", "query", "for", "the", "given", "entity" ]
85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428
https://github.com/face-orm/face/blob/85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428/lib/Face/DiORM.php#L166-L169
7,152
squire-assistant/process
Process.php
Process.getCommandLine
public function getCommandLine() { return is_array($this->commandline) ? implode(' ', array_map(array($this, 'escapeArgument'), $this->commandline)) : $this->commandline; }
php
public function getCommandLine() { return is_array($this->commandline) ? implode(' ', array_map(array($this, 'escapeArgument'), $this->commandline)) : $this->commandline; }
[ "public", "function", "getCommandLine", "(", ")", "{", "return", "is_array", "(", "$", "this", "->", "commandline", ")", "?", "implode", "(", "' '", ",", "array_map", "(", "array", "(", "$", "this", ",", "'escapeArgument'", ")", ",", "$", "this", "->", "commandline", ")", ")", ":", "$", "this", "->", "commandline", ";", "}" ]
Gets the command line to be executed. @return string The command to execute
[ "Gets", "the", "command", "line", "to", "be", "executed", "." ]
472d47ef8f312fc0c6c1eb26df1e508550aea243
https://github.com/squire-assistant/process/blob/472d47ef8f312fc0c6c1eb26df1e508550aea243/Process.php#L937-L940
7,153
squire-assistant/process
Process.php
Process.setOptions
public function setOptions(array $options) { @trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED); $this->options = $options; return $this; }
php
public function setOptions(array $options) { @trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0.', __METHOD__), E_USER_DEPRECATED); $this->options = $options; return $this; }
[ "public", "function", "setOptions", "(", "array", "$", "options", ")", "{", "@", "trigger_error", "(", "sprintf", "(", "'The %s() method is deprecated since version 3.3 and will be removed in 4.0.'", ",", "__METHOD__", ")", ",", "E_USER_DEPRECATED", ")", ";", "$", "this", "->", "options", "=", "$", "options", ";", "return", "$", "this", ";", "}" ]
Sets the options for proc_open. @param array $options The new options @return self The current Process instance @deprecated since version 3.3, to be removed in 4.0.
[ "Sets", "the", "options", "for", "proc_open", "." ]
472d47ef8f312fc0c6c1eb26df1e508550aea243
https://github.com/squire-assistant/process/blob/472d47ef8f312fc0c6c1eb26df1e508550aea243/Process.php#L1204-L1211
7,154
squire-assistant/process
Process.php
Process.setEnhanceWindowsCompatibility
public function setEnhanceWindowsCompatibility($enhance) { @trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Enhanced Windows compatibility will always be enabled.', __METHOD__), E_USER_DEPRECATED); $this->enhanceWindowsCompatibility = (bool) $enhance; return $this; }
php
public function setEnhanceWindowsCompatibility($enhance) { @trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Enhanced Windows compatibility will always be enabled.', __METHOD__), E_USER_DEPRECATED); $this->enhanceWindowsCompatibility = (bool) $enhance; return $this; }
[ "public", "function", "setEnhanceWindowsCompatibility", "(", "$", "enhance", ")", "{", "@", "trigger_error", "(", "sprintf", "(", "'The %s() method is deprecated since version 3.3 and will be removed in 4.0. Enhanced Windows compatibility will always be enabled.'", ",", "__METHOD__", ")", ",", "E_USER_DEPRECATED", ")", ";", "$", "this", "->", "enhanceWindowsCompatibility", "=", "(", "bool", ")", "$", "enhance", ";", "return", "$", "this", ";", "}" ]
Sets whether or not Windows compatibility is enabled. @param bool $enhance @return self The current Process instance @deprecated since version 3.3, to be removed in 4.0. Enhanced Windows compatibility will always be enabled.
[ "Sets", "whether", "or", "not", "Windows", "compatibility", "is", "enabled", "." ]
472d47ef8f312fc0c6c1eb26df1e508550aea243
https://github.com/squire-assistant/process/blob/472d47ef8f312fc0c6c1eb26df1e508550aea243/Process.php#L1238-L1245
7,155
squire-assistant/process
Process.php
Process.setEnhanceSigchildCompatibility
public function setEnhanceSigchildCompatibility($enhance) { @trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Sigchild compatibility will always be enabled.', __METHOD__), E_USER_DEPRECATED); $this->enhanceSigchildCompatibility = (bool) $enhance; return $this; }
php
public function setEnhanceSigchildCompatibility($enhance) { @trigger_error(sprintf('The %s() method is deprecated since version 3.3 and will be removed in 4.0. Sigchild compatibility will always be enabled.', __METHOD__), E_USER_DEPRECATED); $this->enhanceSigchildCompatibility = (bool) $enhance; return $this; }
[ "public", "function", "setEnhanceSigchildCompatibility", "(", "$", "enhance", ")", "{", "@", "trigger_error", "(", "sprintf", "(", "'The %s() method is deprecated since version 3.3 and will be removed in 4.0. Sigchild compatibility will always be enabled.'", ",", "__METHOD__", ")", ",", "E_USER_DEPRECATED", ")", ";", "$", "this", "->", "enhanceSigchildCompatibility", "=", "(", "bool", ")", "$", "enhance", ";", "return", "$", "this", ";", "}" ]
Activates sigchild compatibility mode. Sigchild compatibility mode is required to get the exit code and determine the success of a process when PHP has been compiled with the --enable-sigchild option @param bool $enhance @return self The current Process instance @deprecated since version 3.3, to be removed in 4.0.
[ "Activates", "sigchild", "compatibility", "mode", "." ]
472d47ef8f312fc0c6c1eb26df1e508550aea243
https://github.com/squire-assistant/process/blob/472d47ef8f312fc0c6c1eb26df1e508550aea243/Process.php#L1274-L1281
7,156
SergioMadness/framework
framework/basic/RouteHandler.php
RouteHandler.getHandlerByName
public static function getHandlerByName($name) { return isset(self::$namedRoutes[$name]) ? self::$namedRoutes[$name][1] : null; }
php
public static function getHandlerByName($name) { return isset(self::$namedRoutes[$name]) ? self::$namedRoutes[$name][1] : null; }
[ "public", "static", "function", "getHandlerByName", "(", "$", "name", ")", "{", "return", "isset", "(", "self", "::", "$", "namedRoutes", "[", "$", "name", "]", ")", "?", "self", "::", "$", "namedRoutes", "[", "$", "name", "]", "[", "1", "]", ":", "null", ";", "}" ]
Get handler by name @param string $name @return string
[ "Get", "handler", "by", "name" ]
a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e
https://github.com/SergioMadness/framework/blob/a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e/framework/basic/RouteHandler.php#L81-L84
7,157
SergioMadness/framework
framework/basic/RouteHandler.php
RouteHandler.getHandlerByPath
public static function getHandlerByPath($path) { $result = null; $path = self::prepareRoute('/'.trim($path, " /")); foreach (static::$routes as $key => $handler) { $matches = []; if (preg_match('#'.$key.'$#i', $path, $matches)) { foreach ($matches as $key => $val) { if (!is_numeric($key)) { $_GET[$key] = $val; } } $result = $handler[1]; break; } } return $result; }
php
public static function getHandlerByPath($path) { $result = null; $path = self::prepareRoute('/'.trim($path, " /")); foreach (static::$routes as $key => $handler) { $matches = []; if (preg_match('#'.$key.'$#i', $path, $matches)) { foreach ($matches as $key => $val) { if (!is_numeric($key)) { $_GET[$key] = $val; } } $result = $handler[1]; break; } } return $result; }
[ "public", "static", "function", "getHandlerByPath", "(", "$", "path", ")", "{", "$", "result", "=", "null", ";", "$", "path", "=", "self", "::", "prepareRoute", "(", "'/'", ".", "trim", "(", "$", "path", ",", "\" /\"", ")", ")", ";", "foreach", "(", "static", "::", "$", "routes", "as", "$", "key", "=>", "$", "handler", ")", "{", "$", "matches", "=", "[", "]", ";", "if", "(", "preg_match", "(", "'#'", ".", "$", "key", ".", "'$#i'", ",", "$", "path", ",", "$", "matches", ")", ")", "{", "foreach", "(", "$", "matches", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "key", ")", ")", "{", "$", "_GET", "[", "$", "key", "]", "=", "$", "val", ";", "}", "}", "$", "result", "=", "$", "handler", "[", "1", "]", ";", "break", ";", "}", "}", "return", "$", "result", ";", "}" ]
Get handler by path @param string $path @return string
[ "Get", "handler", "by", "path" ]
a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e
https://github.com/SergioMadness/framework/blob/a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e/framework/basic/RouteHandler.php#L92-L110
7,158
SergioMadness/framework
framework/basic/RouteHandler.php
RouteHandler.parseRoute
public static function parseRoute($url) { $result = null; $parts = explode('/', trim($url, '/')); if (count($parts) === 1) { $parts[0] = $parts[0] === '' ? self::DEFAULT_CONTROLLER : $parts[0]; $parts[1] = self::DEFAULT_ACTION; } $action = static::preparePart(array_pop($parts), true); $parts[count($parts) - 1] = static::preparePart($parts[count($parts) - 1]).'Controller'; $controller = '\\project\\controllers\\'.implode('\\', $parts); if ($action != '' && $controller != '') { $result = $controller.'::'.$action; } return $result; }
php
public static function parseRoute($url) { $result = null; $parts = explode('/', trim($url, '/')); if (count($parts) === 1) { $parts[0] = $parts[0] === '' ? self::DEFAULT_CONTROLLER : $parts[0]; $parts[1] = self::DEFAULT_ACTION; } $action = static::preparePart(array_pop($parts), true); $parts[count($parts) - 1] = static::preparePart($parts[count($parts) - 1]).'Controller'; $controller = '\\project\\controllers\\'.implode('\\', $parts); if ($action != '' && $controller != '') { $result = $controller.'::'.$action; } return $result; }
[ "public", "static", "function", "parseRoute", "(", "$", "url", ")", "{", "$", "result", "=", "null", ";", "$", "parts", "=", "explode", "(", "'/'", ",", "trim", "(", "$", "url", ",", "'/'", ")", ")", ";", "if", "(", "count", "(", "$", "parts", ")", "===", "1", ")", "{", "$", "parts", "[", "0", "]", "=", "$", "parts", "[", "0", "]", "===", "''", "?", "self", "::", "DEFAULT_CONTROLLER", ":", "$", "parts", "[", "0", "]", ";", "$", "parts", "[", "1", "]", "=", "self", "::", "DEFAULT_ACTION", ";", "}", "$", "action", "=", "static", "::", "preparePart", "(", "array_pop", "(", "$", "parts", ")", ",", "true", ")", ";", "$", "parts", "[", "count", "(", "$", "parts", ")", "-", "1", "]", "=", "static", "::", "preparePart", "(", "$", "parts", "[", "count", "(", "$", "parts", ")", "-", "1", "]", ")", ".", "'Controller'", ";", "$", "controller", "=", "'\\\\project\\\\controllers\\\\'", ".", "implode", "(", "'\\\\'", ",", "$", "parts", ")", ";", "if", "(", "$", "action", "!=", "''", "&&", "$", "controller", "!=", "''", ")", "{", "$", "result", "=", "$", "controller", ".", "'::'", ".", "$", "action", ";", "}", "return", "$", "result", ";", "}" ]
Parse url to callable @param string $url @return string
[ "Parse", "url", "to", "callable" ]
a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e
https://github.com/SergioMadness/framework/blob/a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e/framework/basic/RouteHandler.php#L118-L138
7,159
SergioMadness/framework
framework/basic/RouteHandler.php
RouteHandler.preparePart
public static function preparePart($part, $firstLower = false) { $result = str_replace(' ', '', ucwords(str_replace('-', ' ', $part))); if ($firstLower && mb_strlen($result) > 0) { $result[0] = mb_strtolower($result[0]); } return $result; }
php
public static function preparePart($part, $firstLower = false) { $result = str_replace(' ', '', ucwords(str_replace('-', ' ', $part))); if ($firstLower && mb_strlen($result) > 0) { $result[0] = mb_strtolower($result[0]); } return $result; }
[ "public", "static", "function", "preparePart", "(", "$", "part", ",", "$", "firstLower", "=", "false", ")", "{", "$", "result", "=", "str_replace", "(", "' '", ",", "''", ",", "ucwords", "(", "str_replace", "(", "'-'", ",", "' '", ",", "$", "part", ")", ")", ")", ";", "if", "(", "$", "firstLower", "&&", "mb_strlen", "(", "$", "result", ")", ">", "0", ")", "{", "$", "result", "[", "0", "]", "=", "mb_strtolower", "(", "$", "result", "[", "0", "]", ")", ";", "}", "return", "$", "result", ";", "}" ]
Converts main-action to mainAction @param string $part @return string
[ "Converts", "main", "-", "action", "to", "mainAction" ]
a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e
https://github.com/SergioMadness/framework/blob/a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e/framework/basic/RouteHandler.php#L146-L153
7,160
Stratadox/HydrationMapper
src/Instruction/Is.php
Is.type
private static function type( string $className, string $constructor = self::SAME_KEY, string $key = null ): DefinesTheType { return new Is($className, $constructor, [], $key); }
php
private static function type( string $className, string $constructor = self::SAME_KEY, string $key = null ): DefinesTheType { return new Is($className, $constructor, [], $key); }
[ "private", "static", "function", "type", "(", "string", "$", "className", ",", "string", "$", "constructor", "=", "self", "::", "SAME_KEY", ",", "string", "$", "key", "=", "null", ")", ":", "DefinesTheType", "{", "return", "new", "Is", "(", "$", "className", ",", "$", "constructor", ",", "[", "]", ",", "$", "key", ")", ";", "}" ]
Declare that the property is of the type. @param string $className Class name of the property mapping. @param string $constructor Constructor name to use. @param string|null $key Data key to use. @return DefinesTheType The mapping instruction.
[ "Declare", "that", "the", "property", "is", "of", "the", "type", "." ]
d9bf1f10b7626312e0a2466a2ef255ec972acb41
https://github.com/Stratadox/HydrationMapper/blob/d9bf1f10b7626312e0a2466a2ef255ec972acb41/src/Instruction/Is.php#L137-L143
7,161
Stratadox/HydrationMapper
src/Instruction/Is.php
Is.decoratedType
private static function decoratedType( string $className, string $constructor, array $decorators, string $key = null ): DefinesTheType { return new Is($className, $constructor, $decorators, $key); }
php
private static function decoratedType( string $className, string $constructor, array $decorators, string $key = null ): DefinesTheType { return new Is($className, $constructor, $decorators, $key); }
[ "private", "static", "function", "decoratedType", "(", "string", "$", "className", ",", "string", "$", "constructor", ",", "array", "$", "decorators", ",", "string", "$", "key", "=", "null", ")", ":", "DefinesTheType", "{", "return", "new", "Is", "(", "$", "className", ",", "$", "constructor", ",", "$", "decorators", ",", "$", "key", ")", ";", "}" ]
Declare that the property is of the decorated type. @param string $className Class name of the property mapping. @param string $constructor Constructor name to use. @param string[] $decorators Decorator full constructor names. @param string|null $key Data key to use. @return DefinesTheType The mapping instruction.
[ "Declare", "that", "the", "property", "is", "of", "the", "decorated", "type", "." ]
d9bf1f10b7626312e0a2466a2ef255ec972acb41
https://github.com/Stratadox/HydrationMapper/blob/d9bf1f10b7626312e0a2466a2ef255ec972acb41/src/Instruction/Is.php#L154-L161
7,162
coolms/common
src/View/Helper/Decorator/Decorator.php
Decorator.prepare
protected function prepare($markup, $decorators) { $param_arr = func_get_args(); if (is_array($decorators)) { $param_arr[1] = new \ArrayObject($decorators); } $order = 0; $sortAux = []; foreach ($param_arr[1] as $decorator => $options) { if (!is_string($decorator) && is_string($options)) { $param_arr[1][$options] = []; continue; } elseif (is_callable($options)) { $options = call_user_func_array($options, $param_arr); $param_arr[1][$decorator] = $options; } if (!is_array($options)) { continue; } if (!isset($options['order'])) { $plugin = $this->getDecoratorHelper( empty($options['type']) ? $decorator : $options['type'] ); if ($plugin instanceof OrderedDecoratorInterface) { $order = $plugin->getOrder(); } $options['order'] = $order; } else { $order = (int) $options['order']; } $sortAux[] = $options['order']; $order += $this->orderStep; } $param_arr[1] = ArrayUtils::iteratorToArray($param_arr[1]); $param_arr[1] = array_filter($param_arr[1], 'is_array'); array_multisort($sortAux, SORT_ASC, SORT_NUMERIC, $param_arr[1]); return $param_arr[1]; }
php
protected function prepare($markup, $decorators) { $param_arr = func_get_args(); if (is_array($decorators)) { $param_arr[1] = new \ArrayObject($decorators); } $order = 0; $sortAux = []; foreach ($param_arr[1] as $decorator => $options) { if (!is_string($decorator) && is_string($options)) { $param_arr[1][$options] = []; continue; } elseif (is_callable($options)) { $options = call_user_func_array($options, $param_arr); $param_arr[1][$decorator] = $options; } if (!is_array($options)) { continue; } if (!isset($options['order'])) { $plugin = $this->getDecoratorHelper( empty($options['type']) ? $decorator : $options['type'] ); if ($plugin instanceof OrderedDecoratorInterface) { $order = $plugin->getOrder(); } $options['order'] = $order; } else { $order = (int) $options['order']; } $sortAux[] = $options['order']; $order += $this->orderStep; } $param_arr[1] = ArrayUtils::iteratorToArray($param_arr[1]); $param_arr[1] = array_filter($param_arr[1], 'is_array'); array_multisort($sortAux, SORT_ASC, SORT_NUMERIC, $param_arr[1]); return $param_arr[1]; }
[ "protected", "function", "prepare", "(", "$", "markup", ",", "$", "decorators", ")", "{", "$", "param_arr", "=", "func_get_args", "(", ")", ";", "if", "(", "is_array", "(", "$", "decorators", ")", ")", "{", "$", "param_arr", "[", "1", "]", "=", "new", "\\", "ArrayObject", "(", "$", "decorators", ")", ";", "}", "$", "order", "=", "0", ";", "$", "sortAux", "=", "[", "]", ";", "foreach", "(", "$", "param_arr", "[", "1", "]", "as", "$", "decorator", "=>", "$", "options", ")", "{", "if", "(", "!", "is_string", "(", "$", "decorator", ")", "&&", "is_string", "(", "$", "options", ")", ")", "{", "$", "param_arr", "[", "1", "]", "[", "$", "options", "]", "=", "[", "]", ";", "continue", ";", "}", "elseif", "(", "is_callable", "(", "$", "options", ")", ")", "{", "$", "options", "=", "call_user_func_array", "(", "$", "options", ",", "$", "param_arr", ")", ";", "$", "param_arr", "[", "1", "]", "[", "$", "decorator", "]", "=", "$", "options", ";", "}", "if", "(", "!", "is_array", "(", "$", "options", ")", ")", "{", "continue", ";", "}", "if", "(", "!", "isset", "(", "$", "options", "[", "'order'", "]", ")", ")", "{", "$", "plugin", "=", "$", "this", "->", "getDecoratorHelper", "(", "empty", "(", "$", "options", "[", "'type'", "]", ")", "?", "$", "decorator", ":", "$", "options", "[", "'type'", "]", ")", ";", "if", "(", "$", "plugin", "instanceof", "OrderedDecoratorInterface", ")", "{", "$", "order", "=", "$", "plugin", "->", "getOrder", "(", ")", ";", "}", "$", "options", "[", "'order'", "]", "=", "$", "order", ";", "}", "else", "{", "$", "order", "=", "(", "int", ")", "$", "options", "[", "'order'", "]", ";", "}", "$", "sortAux", "[", "]", "=", "$", "options", "[", "'order'", "]", ";", "$", "order", "+=", "$", "this", "->", "orderStep", ";", "}", "$", "param_arr", "[", "1", "]", "=", "ArrayUtils", "::", "iteratorToArray", "(", "$", "param_arr", "[", "1", "]", ")", ";", "$", "param_arr", "[", "1", "]", "=", "array_filter", "(", "$", "param_arr", "[", "1", "]", ",", "'is_array'", ")", ";", "array_multisort", "(", "$", "sortAux", ",", "SORT_ASC", ",", "SORT_NUMERIC", ",", "$", "param_arr", "[", "1", "]", ")", ";", "return", "$", "param_arr", "[", "1", "]", ";", "}" ]
Sorts decorators according to 'order' option @param string $markup @param array|\Traversable $decorators @return array
[ "Sorts", "decorators", "according", "to", "order", "option" ]
3572993cdcdb2898cdde396a2f1de9864b193660
https://github.com/coolms/common/blob/3572993cdcdb2898cdde396a2f1de9864b193660/src/View/Helper/Decorator/Decorator.php#L151-L197
7,163
n0m4dz/laracasa
Zend/Gdata/Spreadsheets.php
Zend_Gdata_Spreadsheets.getSpreadsheetFeed
public function getSpreadsheetFeed($location = null) { if ($location == null) { $uri = self::SPREADSHEETS_FEED_URI; } else if ($location instanceof Zend_Gdata_Spreadsheets_DocumentQuery) { if ($location->getDocumentType() == null) { $location->setDocumentType('spreadsheets'); } $uri = $location->getQueryUrl(); } else { $uri = $location; } return parent::getFeed($uri, 'Zend_Gdata_Spreadsheets_SpreadsheetFeed'); }
php
public function getSpreadsheetFeed($location = null) { if ($location == null) { $uri = self::SPREADSHEETS_FEED_URI; } else if ($location instanceof Zend_Gdata_Spreadsheets_DocumentQuery) { if ($location->getDocumentType() == null) { $location->setDocumentType('spreadsheets'); } $uri = $location->getQueryUrl(); } else { $uri = $location; } return parent::getFeed($uri, 'Zend_Gdata_Spreadsheets_SpreadsheetFeed'); }
[ "public", "function", "getSpreadsheetFeed", "(", "$", "location", "=", "null", ")", "{", "if", "(", "$", "location", "==", "null", ")", "{", "$", "uri", "=", "self", "::", "SPREADSHEETS_FEED_URI", ";", "}", "else", "if", "(", "$", "location", "instanceof", "Zend_Gdata_Spreadsheets_DocumentQuery", ")", "{", "if", "(", "$", "location", "->", "getDocumentType", "(", ")", "==", "null", ")", "{", "$", "location", "->", "setDocumentType", "(", "'spreadsheets'", ")", ";", "}", "$", "uri", "=", "$", "location", "->", "getQueryUrl", "(", ")", ";", "}", "else", "{", "$", "uri", "=", "$", "location", ";", "}", "return", "parent", "::", "getFeed", "(", "$", "uri", ",", "'Zend_Gdata_Spreadsheets_SpreadsheetFeed'", ")", ";", "}" ]
Gets a spreadsheet feed. @param mixed $location A DocumentQuery or a string URI specifying the feed location. @return Zend_Gdata_Spreadsheets_SpreadsheetFeed
[ "Gets", "a", "spreadsheet", "feed", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Spreadsheets.php#L137-L151
7,164
n0m4dz/laracasa
Zend/Gdata/Spreadsheets.php
Zend_Gdata_Spreadsheets.getWorksheetFeed
public function getWorksheetFeed($location) { if ($location instanceof Zend_Gdata_Spreadsheets_DocumentQuery) { if ($location->getDocumentType() == null) { $location->setDocumentType('worksheets'); } $uri = $location->getQueryUrl(); } else if ($location instanceof Zend_Gdata_Spreadsheets_SpreadsheetEntry) { $uri = $location->getLink(self::WORKSHEETS_FEED_LINK_URI)->href; } else { $uri = $location; } return parent::getFeed($uri, 'Zend_Gdata_Spreadsheets_WorksheetFeed'); }
php
public function getWorksheetFeed($location) { if ($location instanceof Zend_Gdata_Spreadsheets_DocumentQuery) { if ($location->getDocumentType() == null) { $location->setDocumentType('worksheets'); } $uri = $location->getQueryUrl(); } else if ($location instanceof Zend_Gdata_Spreadsheets_SpreadsheetEntry) { $uri = $location->getLink(self::WORKSHEETS_FEED_LINK_URI)->href; } else { $uri = $location; } return parent::getFeed($uri, 'Zend_Gdata_Spreadsheets_WorksheetFeed'); }
[ "public", "function", "getWorksheetFeed", "(", "$", "location", ")", "{", "if", "(", "$", "location", "instanceof", "Zend_Gdata_Spreadsheets_DocumentQuery", ")", "{", "if", "(", "$", "location", "->", "getDocumentType", "(", ")", "==", "null", ")", "{", "$", "location", "->", "setDocumentType", "(", "'worksheets'", ")", ";", "}", "$", "uri", "=", "$", "location", "->", "getQueryUrl", "(", ")", ";", "}", "else", "if", "(", "$", "location", "instanceof", "Zend_Gdata_Spreadsheets_SpreadsheetEntry", ")", "{", "$", "uri", "=", "$", "location", "->", "getLink", "(", "self", "::", "WORKSHEETS_FEED_LINK_URI", ")", "->", "href", ";", "}", "else", "{", "$", "uri", "=", "$", "location", ";", "}", "return", "parent", "::", "getFeed", "(", "$", "uri", ",", "'Zend_Gdata_Spreadsheets_WorksheetFeed'", ")", ";", "}" ]
Gets a worksheet feed. @param mixed $location A DocumentQuery, SpreadsheetEntry, or a string URI @return Zend_Gdata_Spreadsheets_WorksheetFeed The feed of worksheets
[ "Gets", "a", "worksheet", "feed", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Spreadsheets.php#L179-L193
7,165
n0m4dz/laracasa
Zend/Gdata/Spreadsheets.php
Zend_Gdata_Spreadsheets.GetWorksheetEntry
public function GetWorksheetEntry($location) { if ($location instanceof Zend_Gdata_Spreadsheets_DocumentQuery) { if ($location->getDocumentType() == null) { $location->setDocumentType('worksheets'); } $uri = $location->getQueryUrl(); } else { $uri = $location; } return parent::getEntry($uri, 'Zend_Gdata_Spreadsheets_WorksheetEntry'); }
php
public function GetWorksheetEntry($location) { if ($location instanceof Zend_Gdata_Spreadsheets_DocumentQuery) { if ($location->getDocumentType() == null) { $location->setDocumentType('worksheets'); } $uri = $location->getQueryUrl(); } else { $uri = $location; } return parent::getEntry($uri, 'Zend_Gdata_Spreadsheets_WorksheetEntry'); }
[ "public", "function", "GetWorksheetEntry", "(", "$", "location", ")", "{", "if", "(", "$", "location", "instanceof", "Zend_Gdata_Spreadsheets_DocumentQuery", ")", "{", "if", "(", "$", "location", "->", "getDocumentType", "(", ")", "==", "null", ")", "{", "$", "location", "->", "setDocumentType", "(", "'worksheets'", ")", ";", "}", "$", "uri", "=", "$", "location", "->", "getQueryUrl", "(", ")", ";", "}", "else", "{", "$", "uri", "=", "$", "location", ";", "}", "return", "parent", "::", "getEntry", "(", "$", "uri", ",", "'Zend_Gdata_Spreadsheets_WorksheetEntry'", ")", ";", "}" ]
Gets a worksheet entry. @param string $location A DocumentQuery or a URI specifying the entry location. @return WorksheetEntry
[ "Gets", "a", "worksheet", "entry", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Spreadsheets.php#L201-L213
7,166
n0m4dz/laracasa
Zend/Gdata/Spreadsheets.php
Zend_Gdata_Spreadsheets.getCellFeed
public function getCellFeed($location) { if ($location instanceof Zend_Gdata_Spreadsheets_CellQuery) { $uri = $location->getQueryUrl(); } else if ($location instanceof Zend_Gdata_Spreadsheets_WorksheetEntry) { $uri = $location->getLink(self::CELL_FEED_LINK_URI)->href; } else { $uri = $location; } return parent::getFeed($uri, 'Zend_Gdata_Spreadsheets_CellFeed'); }
php
public function getCellFeed($location) { if ($location instanceof Zend_Gdata_Spreadsheets_CellQuery) { $uri = $location->getQueryUrl(); } else if ($location instanceof Zend_Gdata_Spreadsheets_WorksheetEntry) { $uri = $location->getLink(self::CELL_FEED_LINK_URI)->href; } else { $uri = $location; } return parent::getFeed($uri, 'Zend_Gdata_Spreadsheets_CellFeed'); }
[ "public", "function", "getCellFeed", "(", "$", "location", ")", "{", "if", "(", "$", "location", "instanceof", "Zend_Gdata_Spreadsheets_CellQuery", ")", "{", "$", "uri", "=", "$", "location", "->", "getQueryUrl", "(", ")", ";", "}", "else", "if", "(", "$", "location", "instanceof", "Zend_Gdata_Spreadsheets_WorksheetEntry", ")", "{", "$", "uri", "=", "$", "location", "->", "getLink", "(", "self", "::", "CELL_FEED_LINK_URI", ")", "->", "href", ";", "}", "else", "{", "$", "uri", "=", "$", "location", ";", "}", "return", "parent", "::", "getFeed", "(", "$", "uri", ",", "'Zend_Gdata_Spreadsheets_CellFeed'", ")", ";", "}" ]
Gets a cell feed. @param string $location A CellQuery, WorksheetEntry or a URI specifying the feed location. @return CellFeed
[ "Gets", "a", "cell", "feed", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Spreadsheets.php#L221-L231
7,167
n0m4dz/laracasa
Zend/Gdata/Spreadsheets.php
Zend_Gdata_Spreadsheets.getCellEntry
public function getCellEntry($location) { if ($location instanceof Zend_Gdata_Spreadsheets_CellQuery) { $uri = $location->getQueryUrl(); } else { $uri = $location; } return parent::getEntry($uri, 'Zend_Gdata_Spreadsheets_CellEntry'); }
php
public function getCellEntry($location) { if ($location instanceof Zend_Gdata_Spreadsheets_CellQuery) { $uri = $location->getQueryUrl(); } else { $uri = $location; } return parent::getEntry($uri, 'Zend_Gdata_Spreadsheets_CellEntry'); }
[ "public", "function", "getCellEntry", "(", "$", "location", ")", "{", "if", "(", "$", "location", "instanceof", "Zend_Gdata_Spreadsheets_CellQuery", ")", "{", "$", "uri", "=", "$", "location", "->", "getQueryUrl", "(", ")", ";", "}", "else", "{", "$", "uri", "=", "$", "location", ";", "}", "return", "parent", "::", "getEntry", "(", "$", "uri", ",", "'Zend_Gdata_Spreadsheets_CellEntry'", ")", ";", "}" ]
Gets a cell entry. @param string $location A CellQuery or a URI specifying the entry location. @return CellEntry
[ "Gets", "a", "cell", "entry", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Spreadsheets.php#L239-L248
7,168
n0m4dz/laracasa
Zend/Gdata/Spreadsheets.php
Zend_Gdata_Spreadsheets.getListFeed
public function getListFeed($location) { if ($location instanceof Zend_Gdata_Spreadsheets_ListQuery) { $uri = $location->getQueryUrl(); } else if ($location instanceof Zend_Gdata_Spreadsheets_WorksheetEntry) { $uri = $location->getLink(self::LIST_FEED_LINK_URI)->href; } else { $uri = $location; } return parent::getFeed($uri, 'Zend_Gdata_Spreadsheets_ListFeed'); }
php
public function getListFeed($location) { if ($location instanceof Zend_Gdata_Spreadsheets_ListQuery) { $uri = $location->getQueryUrl(); } else if ($location instanceof Zend_Gdata_Spreadsheets_WorksheetEntry) { $uri = $location->getLink(self::LIST_FEED_LINK_URI)->href; } else { $uri = $location; } return parent::getFeed($uri, 'Zend_Gdata_Spreadsheets_ListFeed'); }
[ "public", "function", "getListFeed", "(", "$", "location", ")", "{", "if", "(", "$", "location", "instanceof", "Zend_Gdata_Spreadsheets_ListQuery", ")", "{", "$", "uri", "=", "$", "location", "->", "getQueryUrl", "(", ")", ";", "}", "else", "if", "(", "$", "location", "instanceof", "Zend_Gdata_Spreadsheets_WorksheetEntry", ")", "{", "$", "uri", "=", "$", "location", "->", "getLink", "(", "self", "::", "LIST_FEED_LINK_URI", ")", "->", "href", ";", "}", "else", "{", "$", "uri", "=", "$", "location", ";", "}", "return", "parent", "::", "getFeed", "(", "$", "uri", ",", "'Zend_Gdata_Spreadsheets_ListFeed'", ")", ";", "}" ]
Gets a list feed. @param mixed $location A ListQuery, WorksheetEntry or string URI specifying the feed location. @return ListFeed
[ "Gets", "a", "list", "feed", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Spreadsheets.php#L256-L267
7,169
n0m4dz/laracasa
Zend/Gdata/Spreadsheets.php
Zend_Gdata_Spreadsheets.getListEntry
public function getListEntry($location) { if ($location instanceof Zend_Gdata_Spreadsheets_ListQuery) { $uri = $location->getQueryUrl(); } else { $uri = $location; } return parent::getEntry($uri, 'Zend_Gdata_Spreadsheets_ListEntry'); }
php
public function getListEntry($location) { if ($location instanceof Zend_Gdata_Spreadsheets_ListQuery) { $uri = $location->getQueryUrl(); } else { $uri = $location; } return parent::getEntry($uri, 'Zend_Gdata_Spreadsheets_ListEntry'); }
[ "public", "function", "getListEntry", "(", "$", "location", ")", "{", "if", "(", "$", "location", "instanceof", "Zend_Gdata_Spreadsheets_ListQuery", ")", "{", "$", "uri", "=", "$", "location", "->", "getQueryUrl", "(", ")", ";", "}", "else", "{", "$", "uri", "=", "$", "location", ";", "}", "return", "parent", "::", "getEntry", "(", "$", "uri", ",", "'Zend_Gdata_Spreadsheets_ListEntry'", ")", ";", "}" ]
Gets a list entry. @param string $location A ListQuery or a URI specifying the entry location. @return ListEntry
[ "Gets", "a", "list", "entry", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Spreadsheets.php#L275-L284
7,170
n0m4dz/laracasa
Zend/Gdata/Spreadsheets.php
Zend_Gdata_Spreadsheets.updateCell
public function updateCell($row, $col, $inputValue, $key, $wkshtId = 'default') { $cell = 'R'.$row.'C'.$col; $query = new Zend_Gdata_Spreadsheets_CellQuery(); $query->setSpreadsheetKey($key); $query->setWorksheetId($wkshtId); $query->setCellId($cell); $entry = $this->getCellEntry($query); $entry->setCell(new Zend_Gdata_Spreadsheets_Extension_Cell(null, $row, $col, $inputValue)); $response = $entry->save(); return $response; }
php
public function updateCell($row, $col, $inputValue, $key, $wkshtId = 'default') { $cell = 'R'.$row.'C'.$col; $query = new Zend_Gdata_Spreadsheets_CellQuery(); $query->setSpreadsheetKey($key); $query->setWorksheetId($wkshtId); $query->setCellId($cell); $entry = $this->getCellEntry($query); $entry->setCell(new Zend_Gdata_Spreadsheets_Extension_Cell(null, $row, $col, $inputValue)); $response = $entry->save(); return $response; }
[ "public", "function", "updateCell", "(", "$", "row", ",", "$", "col", ",", "$", "inputValue", ",", "$", "key", ",", "$", "wkshtId", "=", "'default'", ")", "{", "$", "cell", "=", "'R'", ".", "$", "row", ".", "'C'", ".", "$", "col", ";", "$", "query", "=", "new", "Zend_Gdata_Spreadsheets_CellQuery", "(", ")", ";", "$", "query", "->", "setSpreadsheetKey", "(", "$", "key", ")", ";", "$", "query", "->", "setWorksheetId", "(", "$", "wkshtId", ")", ";", "$", "query", "->", "setCellId", "(", "$", "cell", ")", ";", "$", "entry", "=", "$", "this", "->", "getCellEntry", "(", "$", "query", ")", ";", "$", "entry", "->", "setCell", "(", "new", "Zend_Gdata_Spreadsheets_Extension_Cell", "(", "null", ",", "$", "row", ",", "$", "col", ",", "$", "inputValue", ")", ")", ";", "$", "response", "=", "$", "entry", "->", "save", "(", ")", ";", "return", "$", "response", ";", "}" ]
Updates an existing cell. @param int $row The row containing the cell to update @param int $col The column containing the cell to update @param int $inputValue The new value for the cell @param string $key The key for the spreadsheet to be updated @param string $wkshtId (optional) The worksheet to be updated @return CellEntry The updated cell entry.
[ "Updates", "an", "existing", "cell", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Spreadsheets.php#L296-L309
7,171
n0m4dz/laracasa
Zend/Gdata/Spreadsheets.php
Zend_Gdata_Spreadsheets.insertRow
public function insertRow($rowData, $key, $wkshtId = 'default') { $newEntry = new Zend_Gdata_Spreadsheets_ListEntry(); $newCustomArr = array(); foreach ($rowData as $k => $v) { $newCustom = new Zend_Gdata_Spreadsheets_Extension_Custom(); $newCustom->setText($v)->setColumnName($k); $newEntry->addCustom($newCustom); } $query = new Zend_Gdata_Spreadsheets_ListQuery(); $query->setSpreadsheetKey($key); $query->setWorksheetId($wkshtId); $feed = $this->getListFeed($query); $editLink = $feed->getLink('http://schemas.google.com/g/2005#post'); return $this->insertEntry($newEntry->saveXML(), $editLink->href, 'Zend_Gdata_Spreadsheets_ListEntry'); }
php
public function insertRow($rowData, $key, $wkshtId = 'default') { $newEntry = new Zend_Gdata_Spreadsheets_ListEntry(); $newCustomArr = array(); foreach ($rowData as $k => $v) { $newCustom = new Zend_Gdata_Spreadsheets_Extension_Custom(); $newCustom->setText($v)->setColumnName($k); $newEntry->addCustom($newCustom); } $query = new Zend_Gdata_Spreadsheets_ListQuery(); $query->setSpreadsheetKey($key); $query->setWorksheetId($wkshtId); $feed = $this->getListFeed($query); $editLink = $feed->getLink('http://schemas.google.com/g/2005#post'); return $this->insertEntry($newEntry->saveXML(), $editLink->href, 'Zend_Gdata_Spreadsheets_ListEntry'); }
[ "public", "function", "insertRow", "(", "$", "rowData", ",", "$", "key", ",", "$", "wkshtId", "=", "'default'", ")", "{", "$", "newEntry", "=", "new", "Zend_Gdata_Spreadsheets_ListEntry", "(", ")", ";", "$", "newCustomArr", "=", "array", "(", ")", ";", "foreach", "(", "$", "rowData", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "newCustom", "=", "new", "Zend_Gdata_Spreadsheets_Extension_Custom", "(", ")", ";", "$", "newCustom", "->", "setText", "(", "$", "v", ")", "->", "setColumnName", "(", "$", "k", ")", ";", "$", "newEntry", "->", "addCustom", "(", "$", "newCustom", ")", ";", "}", "$", "query", "=", "new", "Zend_Gdata_Spreadsheets_ListQuery", "(", ")", ";", "$", "query", "->", "setSpreadsheetKey", "(", "$", "key", ")", ";", "$", "query", "->", "setWorksheetId", "(", "$", "wkshtId", ")", ";", "$", "feed", "=", "$", "this", "->", "getListFeed", "(", "$", "query", ")", ";", "$", "editLink", "=", "$", "feed", "->", "getLink", "(", "'http://schemas.google.com/g/2005#post'", ")", ";", "return", "$", "this", "->", "insertEntry", "(", "$", "newEntry", "->", "saveXML", "(", ")", ",", "$", "editLink", "->", "href", ",", "'Zend_Gdata_Spreadsheets_ListEntry'", ")", ";", "}" ]
Inserts a new row with provided data. @param array $rowData An array of column header to row data @param string $key The key of the spreadsheet to modify @param string $wkshtId (optional) The worksheet to modify @return ListEntry The inserted row
[ "Inserts", "a", "new", "row", "with", "provided", "data", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Spreadsheets.php#L319-L337
7,172
n0m4dz/laracasa
Zend/Gdata/Spreadsheets.php
Zend_Gdata_Spreadsheets.updateRow
public function updateRow($entry, $newRowData) { $newCustomArr = array(); foreach ($newRowData as $k => $v) { $newCustom = new Zend_Gdata_Spreadsheets_Extension_Custom(); $newCustom->setText($v)->setColumnName($k); $newCustomArr[] = $newCustom; } $entry->setCustom($newCustomArr); return $entry->save(); }
php
public function updateRow($entry, $newRowData) { $newCustomArr = array(); foreach ($newRowData as $k => $v) { $newCustom = new Zend_Gdata_Spreadsheets_Extension_Custom(); $newCustom->setText($v)->setColumnName($k); $newCustomArr[] = $newCustom; } $entry->setCustom($newCustomArr); return $entry->save(); }
[ "public", "function", "updateRow", "(", "$", "entry", ",", "$", "newRowData", ")", "{", "$", "newCustomArr", "=", "array", "(", ")", ";", "foreach", "(", "$", "newRowData", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "newCustom", "=", "new", "Zend_Gdata_Spreadsheets_Extension_Custom", "(", ")", ";", "$", "newCustom", "->", "setText", "(", "$", "v", ")", "->", "setColumnName", "(", "$", "k", ")", ";", "$", "newCustomArr", "[", "]", "=", "$", "newCustom", ";", "}", "$", "entry", "->", "setCustom", "(", "$", "newCustomArr", ")", ";", "return", "$", "entry", "->", "save", "(", ")", ";", "}" ]
Updates an existing row with provided data. @param ListEntry $entry The row entry to update @param array $newRowData An array of column header to row data
[ "Updates", "an", "existing", "row", "with", "provided", "data", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Spreadsheets.php#L345-L356
7,173
n0m4dz/laracasa
Zend/Gdata/Spreadsheets.php
Zend_Gdata_Spreadsheets.getSpreadsheetListFeedContents
public function getSpreadsheetListFeedContents($location) { $listFeed = $this->getListFeed($location); $listFeed = $this->retrieveAllEntriesForFeed($listFeed); $spreadsheetContents = array(); foreach ($listFeed as $listEntry) { $rowContents = array(); $customArray = $listEntry->getCustom(); foreach ($customArray as $custom) { $rowContents[$custom->getColumnName()] = $custom->getText(); } $spreadsheetContents[] = $rowContents; } return $spreadsheetContents; }
php
public function getSpreadsheetListFeedContents($location) { $listFeed = $this->getListFeed($location); $listFeed = $this->retrieveAllEntriesForFeed($listFeed); $spreadsheetContents = array(); foreach ($listFeed as $listEntry) { $rowContents = array(); $customArray = $listEntry->getCustom(); foreach ($customArray as $custom) { $rowContents[$custom->getColumnName()] = $custom->getText(); } $spreadsheetContents[] = $rowContents; } return $spreadsheetContents; }
[ "public", "function", "getSpreadsheetListFeedContents", "(", "$", "location", ")", "{", "$", "listFeed", "=", "$", "this", "->", "getListFeed", "(", "$", "location", ")", ";", "$", "listFeed", "=", "$", "this", "->", "retrieveAllEntriesForFeed", "(", "$", "listFeed", ")", ";", "$", "spreadsheetContents", "=", "array", "(", ")", ";", "foreach", "(", "$", "listFeed", "as", "$", "listEntry", ")", "{", "$", "rowContents", "=", "array", "(", ")", ";", "$", "customArray", "=", "$", "listEntry", "->", "getCustom", "(", ")", ";", "foreach", "(", "$", "customArray", "as", "$", "custom", ")", "{", "$", "rowContents", "[", "$", "custom", "->", "getColumnName", "(", ")", "]", "=", "$", "custom", "->", "getText", "(", ")", ";", "}", "$", "spreadsheetContents", "[", "]", "=", "$", "rowContents", ";", "}", "return", "$", "spreadsheetContents", ";", "}" ]
Returns the content of all rows as an associative array @param mixed $location A ListQuery or string URI specifying the feed location. @return array An array of rows. Each element of the array is an associative array of data
[ "Returns", "the", "content", "of", "all", "rows", "as", "an", "associative", "array" ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Spreadsheets.php#L374-L388
7,174
coolms/authentication
src/View/Helper/LoginWidget.php
LoginWidget.getForm
public function getForm() { if (null === $this->form) { $this->setForm($this->getUserService()->getLoginForm()); } return $this->form; }
php
public function getForm() { if (null === $this->form) { $this->setForm($this->getUserService()->getLoginForm()); } return $this->form; }
[ "public", "function", "getForm", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "form", ")", "{", "$", "this", "->", "setForm", "(", "$", "this", "->", "getUserService", "(", ")", "->", "getLoginForm", "(", ")", ")", ";", "}", "return", "$", "this", "->", "form", ";", "}" ]
Retrieve Login form @return Login
[ "Retrieve", "Login", "form" ]
4563cc4cc3a4d777db45977bd179cc5bd3f57cd8
https://github.com/coolms/authentication/blob/4563cc4cc3a4d777db45977bd179cc5bd3f57cd8/src/View/Helper/LoginWidget.php#L100-L107
7,175
aryelgois/utils
src/Validation.php
Validation.sanitizeArray
public static function sanitizeArray(&$arr) { foreach ($arr as $k => $v) { if (is_string($v)) { $arr[$k] = self::sanitizeInput($v); } } }
php
public static function sanitizeArray(&$arr) { foreach ($arr as $k => $v) { if (is_string($v)) { $arr[$k] = self::sanitizeInput($v); } } }
[ "public", "static", "function", "sanitizeArray", "(", "&", "$", "arr", ")", "{", "foreach", "(", "$", "arr", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "is_string", "(", "$", "v", ")", ")", "{", "$", "arr", "[", "$", "k", "]", "=", "self", "::", "sanitizeInput", "(", "$", "v", ")", ";", "}", "}", "}" ]
Sanitizes all strings of an array @param mixed[] &$arr Only strings are sanitized
[ "Sanitizes", "all", "strings", "of", "an", "array" ]
683a4685de166592aadd0fe7ebec828b99f0cbdc
https://github.com/aryelgois/utils/blob/683a4685de166592aadd0fe7ebec828b99f0cbdc/src/Validation.php#L41-L48
7,176
aryelgois/utils
src/Validation.php
Validation.cnpj
public static function cnpj($cnpj) { // Extract numbers $cnpj = preg_replace('/[^\d]/', '', $cnpj); // Check amount of numbers if (strlen($cnpj) > 14) { return false; } $cnpj = str_pad($cnpj, 14, '0', STR_PAD_LEFT); // Check for same digit sequence if (preg_match('/(\d)\1{13}/', $cnpj)) { return false; } // Remove check digits $value = substr($cnpj, 0, -2); // Calculate check digits $cd = 11 - self::mod11($value); if ($cd >= 10) { $cd = 0; } $value .= $cd; $cd = 11 - self::mod11($value); if ($cd >= 10) { $cd = 0; } $value .= $cd; // Verify if ($cnpj === $value) { return $cnpj; } return false; }
php
public static function cnpj($cnpj) { // Extract numbers $cnpj = preg_replace('/[^\d]/', '', $cnpj); // Check amount of numbers if (strlen($cnpj) > 14) { return false; } $cnpj = str_pad($cnpj, 14, '0', STR_PAD_LEFT); // Check for same digit sequence if (preg_match('/(\d)\1{13}/', $cnpj)) { return false; } // Remove check digits $value = substr($cnpj, 0, -2); // Calculate check digits $cd = 11 - self::mod11($value); if ($cd >= 10) { $cd = 0; } $value .= $cd; $cd = 11 - self::mod11($value); if ($cd >= 10) { $cd = 0; } $value .= $cd; // Verify if ($cnpj === $value) { return $cnpj; } return false; }
[ "public", "static", "function", "cnpj", "(", "$", "cnpj", ")", "{", "// Extract numbers", "$", "cnpj", "=", "preg_replace", "(", "'/[^\\d]/'", ",", "''", ",", "$", "cnpj", ")", ";", "// Check amount of numbers", "if", "(", "strlen", "(", "$", "cnpj", ")", ">", "14", ")", "{", "return", "false", ";", "}", "$", "cnpj", "=", "str_pad", "(", "$", "cnpj", ",", "14", ",", "'0'", ",", "STR_PAD_LEFT", ")", ";", "// Check for same digit sequence", "if", "(", "preg_match", "(", "'/(\\d)\\1{13}/'", ",", "$", "cnpj", ")", ")", "{", "return", "false", ";", "}", "// Remove check digits", "$", "value", "=", "substr", "(", "$", "cnpj", ",", "0", ",", "-", "2", ")", ";", "// Calculate check digits", "$", "cd", "=", "11", "-", "self", "::", "mod11", "(", "$", "value", ")", ";", "if", "(", "$", "cd", ">=", "10", ")", "{", "$", "cd", "=", "0", ";", "}", "$", "value", ".=", "$", "cd", ";", "$", "cd", "=", "11", "-", "self", "::", "mod11", "(", "$", "value", ")", ";", "if", "(", "$", "cd", ">=", "10", ")", "{", "$", "cd", "=", "0", ";", "}", "$", "value", ".=", "$", "cd", ";", "// Verify", "if", "(", "$", "cnpj", "===", "$", "value", ")", "{", "return", "$", "cnpj", ";", "}", "return", "false", ";", "}" ]
Validates Brazilian CNPJ @param string $cnpj Up to 14 digits, anything else is discarded @return string validated (only numbers) @return false if invalid
[ "Validates", "Brazilian", "CNPJ" ]
683a4685de166592aadd0fe7ebec828b99f0cbdc
https://github.com/aryelgois/utils/blob/683a4685de166592aadd0fe7ebec828b99f0cbdc/src/Validation.php#L96-L132
7,177
aryelgois/utils
src/Validation.php
Validation.cpf
public static function cpf($cpf) { // Extract numbers $cpf = preg_replace('/[^\d]/', '', $cpf); // Check amount of numbers if (strlen($cpf) > 11) { return false; } $cpf = str_pad($cpf, 11, '0', STR_PAD_LEFT); // Check for same digit sequence if (preg_match('/(\d)\1{10}/', $cpf)) { return false; } // Calculate check digits for ($t = 9; $t < 11; $t++) { for ($d = 0, $c = 0; $c < $t; $c++) { $d += $cpf{$c} * (($t + 1) - $c); } $d = ((10 * $d) % 11) % 10; if ($cpf{$c} != $d) { return false; } } return $cpf; }
php
public static function cpf($cpf) { // Extract numbers $cpf = preg_replace('/[^\d]/', '', $cpf); // Check amount of numbers if (strlen($cpf) > 11) { return false; } $cpf = str_pad($cpf, 11, '0', STR_PAD_LEFT); // Check for same digit sequence if (preg_match('/(\d)\1{10}/', $cpf)) { return false; } // Calculate check digits for ($t = 9; $t < 11; $t++) { for ($d = 0, $c = 0; $c < $t; $c++) { $d += $cpf{$c} * (($t + 1) - $c); } $d = ((10 * $d) % 11) % 10; if ($cpf{$c} != $d) { return false; } } return $cpf; }
[ "public", "static", "function", "cpf", "(", "$", "cpf", ")", "{", "// Extract numbers", "$", "cpf", "=", "preg_replace", "(", "'/[^\\d]/'", ",", "''", ",", "$", "cpf", ")", ";", "// Check amount of numbers", "if", "(", "strlen", "(", "$", "cpf", ")", ">", "11", ")", "{", "return", "false", ";", "}", "$", "cpf", "=", "str_pad", "(", "$", "cpf", ",", "11", ",", "'0'", ",", "STR_PAD_LEFT", ")", ";", "// Check for same digit sequence", "if", "(", "preg_match", "(", "'/(\\d)\\1{10}/'", ",", "$", "cpf", ")", ")", "{", "return", "false", ";", "}", "// Calculate check digits", "for", "(", "$", "t", "=", "9", ";", "$", "t", "<", "11", ";", "$", "t", "++", ")", "{", "for", "(", "$", "d", "=", "0", ",", "$", "c", "=", "0", ";", "$", "c", "<", "$", "t", ";", "$", "c", "++", ")", "{", "$", "d", "+=", "$", "cpf", "{", "$", "c", "}", "*", "(", "(", "$", "t", "+", "1", ")", "-", "$", "c", ")", ";", "}", "$", "d", "=", "(", "(", "10", "*", "$", "d", ")", "%", "11", ")", "%", "10", ";", "if", "(", "$", "cpf", "{", "$", "c", "}", "!=", "$", "d", ")", "{", "return", "false", ";", "}", "}", "return", "$", "cpf", ";", "}" ]
Validate Brazilian CPF @author rafael-neri (modified) @link https://gist.github.com/rafael-neri/ab3e58803a08cb4def059fce4e3c0e40 @param string $cpf Up to 11 digits, anything else is discarded @return string validated (only numbers) or false if invalid
[ "Validate", "Brazilian", "CPF" ]
683a4685de166592aadd0fe7ebec828b99f0cbdc
https://github.com/aryelgois/utils/blob/683a4685de166592aadd0fe7ebec828b99f0cbdc/src/Validation.php#L144-L172
7,178
aryelgois/utils
src/Validation.php
Validation.mod11Pre
public static function mod11Pre($number, $base = 9) { $checksum = 0; $factor = 2; foreach (str_split(strrev((string) $number)) as $d) { $checksum += $d * $factor; if (++$factor > $base) { $factor = 2; } } return $checksum; }
php
public static function mod11Pre($number, $base = 9) { $checksum = 0; $factor = 2; foreach (str_split(strrev((string) $number)) as $d) { $checksum += $d * $factor; if (++$factor > $base) { $factor = 2; } } return $checksum; }
[ "public", "static", "function", "mod11Pre", "(", "$", "number", ",", "$", "base", "=", "9", ")", "{", "$", "checksum", "=", "0", ";", "$", "factor", "=", "2", ";", "foreach", "(", "str_split", "(", "strrev", "(", "(", "string", ")", "$", "number", ")", ")", "as", "$", "d", ")", "{", "$", "checksum", "+=", "$", "d", "*", "$", "factor", ";", "if", "(", "++", "$", "factor", ">", "$", "base", ")", "{", "$", "factor", "=", "2", ";", "}", "}", "return", "$", "checksum", ";", "}" ]
Calculates modulus 11 but do not apply the modulus Useful when some calculation is required before '% 11' @param mixed $number Numeric value whose check digit will be calculated @param integer $base Maximum multiplication value @return integer
[ "Calculates", "modulus", "11", "but", "do", "not", "apply", "the", "modulus" ]
683a4685de166592aadd0fe7ebec828b99f0cbdc
https://github.com/aryelgois/utils/blob/683a4685de166592aadd0fe7ebec828b99f0cbdc/src/Validation.php#L292-L303
7,179
bishopb/vanilla
library/database/class.dataset.php
Gdn_DataSet._FetchAllRows
protected function _FetchAllRows($DatasetType = FALSE) { if(!is_null($this->_Result)) return; if($DatasetType) $this->_DatasetType = $DatasetType; $Result = array(); if (is_null($this->_PDOStatement)) { $this->_Result = $Result; return; } $Result = $this->_PDOStatement->fetchAll($this->_DatasetType == DATASET_TYPE_ARRAY ? PDO::FETCH_ASSOC : PDO::FETCH_OBJ); // $this->_PDOStatement->setFetchMode($this->_DatasetType == DATASET_TYPE_ARRAY ? PDO::FETCH_ASSOC : PDO::FETCH_OBJ); // while($Row = $this->_PDOStatement->fetch()) { // $Result[] = $Row; // } $this->FreePDOStatement(TRUE); $this->_Result = $Result; }
php
protected function _FetchAllRows($DatasetType = FALSE) { if(!is_null($this->_Result)) return; if($DatasetType) $this->_DatasetType = $DatasetType; $Result = array(); if (is_null($this->_PDOStatement)) { $this->_Result = $Result; return; } $Result = $this->_PDOStatement->fetchAll($this->_DatasetType == DATASET_TYPE_ARRAY ? PDO::FETCH_ASSOC : PDO::FETCH_OBJ); // $this->_PDOStatement->setFetchMode($this->_DatasetType == DATASET_TYPE_ARRAY ? PDO::FETCH_ASSOC : PDO::FETCH_OBJ); // while($Row = $this->_PDOStatement->fetch()) { // $Result[] = $Row; // } $this->FreePDOStatement(TRUE); $this->_Result = $Result; }
[ "protected", "function", "_FetchAllRows", "(", "$", "DatasetType", "=", "FALSE", ")", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "_Result", ")", ")", "return", ";", "if", "(", "$", "DatasetType", ")", "$", "this", "->", "_DatasetType", "=", "$", "DatasetType", ";", "$", "Result", "=", "array", "(", ")", ";", "if", "(", "is_null", "(", "$", "this", "->", "_PDOStatement", ")", ")", "{", "$", "this", "->", "_Result", "=", "$", "Result", ";", "return", ";", "}", "$", "Result", "=", "$", "this", "->", "_PDOStatement", "->", "fetchAll", "(", "$", "this", "->", "_DatasetType", "==", "DATASET_TYPE_ARRAY", "?", "PDO", "::", "FETCH_ASSOC", ":", "PDO", "::", "FETCH_OBJ", ")", ";", "//\t\t$this->_PDOStatement->setFetchMode($this->_DatasetType == DATASET_TYPE_ARRAY ? PDO::FETCH_ASSOC : PDO::FETCH_OBJ);", "// while($Row = $this->_PDOStatement->fetch()) {", "//\t\t\t$Result[] = $Row;", "//\t\t}", "$", "this", "->", "FreePDOStatement", "(", "TRUE", ")", ";", "$", "this", "->", "_Result", "=", "$", "Result", ";", "}" ]
Fetches all rows from the PDOStatement object into the resultset. @param string $DatasetType The format in which the result should be returned: object or array. It will fill a different array depending on which type is specified.
[ "Fetches", "all", "rows", "from", "the", "PDOStatement", "object", "into", "the", "resultset", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/database/class.dataset.php#L140-L162
7,180
bishopb/vanilla
library/database/class.dataset.php
Gdn_DataSet.&
public function &FirstRow($DatasetType = FALSE) { $Result = &$this->Result($DatasetType); if(count($Result) == 0) return $this->_EOF; return $Result[0]; }
php
public function &FirstRow($DatasetType = FALSE) { $Result = &$this->Result($DatasetType); if(count($Result) == 0) return $this->_EOF; return $Result[0]; }
[ "public", "function", "&", "FirstRow", "(", "$", "DatasetType", "=", "FALSE", ")", "{", "$", "Result", "=", "&", "$", "this", "->", "Result", "(", "$", "DatasetType", ")", ";", "if", "(", "count", "(", "$", "Result", ")", "==", "0", ")", "return", "$", "this", "->", "_EOF", ";", "return", "$", "Result", "[", "0", "]", ";", "}" ]
Returns the first row or FALSE if there are no rows to return. @param string $DatasetType The format in which the result should be returned: object or array.
[ "Returns", "the", "first", "row", "or", "FALSE", "if", "there", "are", "no", "rows", "to", "return", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/database/class.dataset.php#L169-L175
7,181
bishopb/vanilla
library/database/class.dataset.php
Gdn_DataSet.Format
public function Format($FormatMethod) { $Result = &$this->Result(); foreach($Result as $Index => $Value) { $Result[$Index] = Gdn_Format::To($Value, $FormatMethod); } return $this; }
php
public function Format($FormatMethod) { $Result = &$this->Result(); foreach($Result as $Index => $Value) { $Result[$Index] = Gdn_Format::To($Value, $FormatMethod); } return $this; }
[ "public", "function", "Format", "(", "$", "FormatMethod", ")", "{", "$", "Result", "=", "&", "$", "this", "->", "Result", "(", ")", ";", "foreach", "(", "$", "Result", "as", "$", "Index", "=>", "$", "Value", ")", "{", "$", "Result", "[", "$", "Index", "]", "=", "Gdn_Format", "::", "To", "(", "$", "Value", ",", "$", "FormatMethod", ")", ";", "}", "return", "$", "this", ";", "}" ]
Format the resultset with the given method. @param string $FormatMethod The method to use with Gdn_Format::To(). @return Gdn_Dataset $this pointer for chaining.
[ "Format", "the", "resultset", "with", "the", "given", "method", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/database/class.dataset.php#L183-L189
7,182
bishopb/vanilla
library/database/class.dataset.php
Gdn_DataSet.Index
public static function Index($Data, $Columns, $Options = array()) { $Columns = (array)$Columns; $Result = array(); $Options = array_change_key_case($Options); if (is_string($Options)) $Options = array('sep' => $Options); $Sep = GetValue('sep', $Options, '|'); $Unique = GetValue('unique', $Options, TRUE); foreach ($Data as $Row) { $IndexValues = array(); foreach ($Columns as $Column) { $IndexValues[] = GetValue($Column, $Row); } $Index = implode($Sep, $IndexValues); if ($Unique) $Result[$Index] = $Row; else $Result[$Index][] = $Row; } return $Result; }
php
public static function Index($Data, $Columns, $Options = array()) { $Columns = (array)$Columns; $Result = array(); $Options = array_change_key_case($Options); if (is_string($Options)) $Options = array('sep' => $Options); $Sep = GetValue('sep', $Options, '|'); $Unique = GetValue('unique', $Options, TRUE); foreach ($Data as $Row) { $IndexValues = array(); foreach ($Columns as $Column) { $IndexValues[] = GetValue($Column, $Row); } $Index = implode($Sep, $IndexValues); if ($Unique) $Result[$Index] = $Row; else $Result[$Index][] = $Row; } return $Result; }
[ "public", "static", "function", "Index", "(", "$", "Data", ",", "$", "Columns", ",", "$", "Options", "=", "array", "(", ")", ")", "{", "$", "Columns", "=", "(", "array", ")", "$", "Columns", ";", "$", "Result", "=", "array", "(", ")", ";", "$", "Options", "=", "array_change_key_case", "(", "$", "Options", ")", ";", "if", "(", "is_string", "(", "$", "Options", ")", ")", "$", "Options", "=", "array", "(", "'sep'", "=>", "$", "Options", ")", ";", "$", "Sep", "=", "GetValue", "(", "'sep'", ",", "$", "Options", ",", "'|'", ")", ";", "$", "Unique", "=", "GetValue", "(", "'unique'", ",", "$", "Options", ",", "TRUE", ")", ";", "foreach", "(", "$", "Data", "as", "$", "Row", ")", "{", "$", "IndexValues", "=", "array", "(", ")", ";", "foreach", "(", "$", "Columns", "as", "$", "Column", ")", "{", "$", "IndexValues", "[", "]", "=", "GetValue", "(", "$", "Column", ",", "$", "Row", ")", ";", "}", "$", "Index", "=", "implode", "(", "$", "Sep", ",", "$", "IndexValues", ")", ";", "if", "(", "$", "Unique", ")", "$", "Result", "[", "$", "Index", "]", "=", "$", "Row", ";", "else", "$", "Result", "[", "$", "Index", "]", "[", "]", "=", "$", "Row", ";", "}", "return", "$", "Result", ";", "}" ]
Index a result array. @param array $Data The array to index. It is formatted similar to the array returned by Gdn_DataSet::Result(). @param string|array $Columns The name of the column to index on or an array of columns to index on. @param array $Options An array of options for the method. - <b>Sep</b>: The string to seperate index columns by. Default '|'. - <b>Unique</b>: Whether or not the results are unique. - <b>true</b> (default): The index is unique. - <b>false</b>: The index is not unique and each indexed row will be an array or arrays. @return type
[ "Index", "a", "result", "array", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/database/class.dataset.php#L220-L244
7,183
bishopb/vanilla
library/database/class.dataset.php
Gdn_DataSet.&
public function &LastRow($DatasetType = FALSE) { $Result = &$this->Result($DatasetType); if (count($Result) == 0) return $this->_EOF; return $Result[count($Result) - 1]; }
php
public function &LastRow($DatasetType = FALSE) { $Result = &$this->Result($DatasetType); if (count($Result) == 0) return $this->_EOF; return $Result[count($Result) - 1]; }
[ "public", "function", "&", "LastRow", "(", "$", "DatasetType", "=", "FALSE", ")", "{", "$", "Result", "=", "&", "$", "this", "->", "Result", "(", "$", "DatasetType", ")", ";", "if", "(", "count", "(", "$", "Result", ")", "==", "0", ")", "return", "$", "this", "->", "_EOF", ";", "return", "$", "Result", "[", "count", "(", "$", "Result", ")", "-", "1", "]", ";", "}" ]
Returns the last row in the or FALSE if there are no rows to return. @param string $DatasetType The format in which the result should be returned: object or array.
[ "Returns", "the", "last", "row", "in", "the", "or", "FALSE", "if", "there", "are", "no", "rows", "to", "return", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/database/class.dataset.php#L415-L421
7,184
bishopb/vanilla
library/database/class.dataset.php
Gdn_DataSet.&
public function &NextRow($DatasetType = FALSE ) { $Result = &$this->Result($DatasetType); ++$this->_Cursor; if(isset($Result[$this->_Cursor])) return $Result[$this->_Cursor]; return $this->_EOF; }
php
public function &NextRow($DatasetType = FALSE ) { $Result = &$this->Result($DatasetType); ++$this->_Cursor; if(isset($Result[$this->_Cursor])) return $Result[$this->_Cursor]; return $this->_EOF; }
[ "public", "function", "&", "NextRow", "(", "$", "DatasetType", "=", "FALSE", ")", "{", "$", "Result", "=", "&", "$", "this", "->", "Result", "(", "$", "DatasetType", ")", ";", "++", "$", "this", "->", "_Cursor", ";", "if", "(", "isset", "(", "$", "Result", "[", "$", "this", "->", "_Cursor", "]", ")", ")", "return", "$", "Result", "[", "$", "this", "->", "_Cursor", "]", ";", "return", "$", "this", "->", "_EOF", ";", "}" ]
Returns the next row or FALSE if there are no more rows. @param string $DatasetType The format in which the result should be returned: object or array.
[ "Returns", "the", "next", "row", "or", "FALSE", "if", "there", "are", "no", "more", "rows", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/database/class.dataset.php#L428-L435
7,185
bishopb/vanilla
library/database/class.dataset.php
Gdn_DataSet.&
public function &PreviousRow($DatasetType = FALSE) { $Result = &$this->Result($DatasetType); --$this->_Cursor; if (isset($Result[$this->_Cursor])) { return $Result[$this->_Cursor]; } return $this->_EOF; }
php
public function &PreviousRow($DatasetType = FALSE) { $Result = &$this->Result($DatasetType); --$this->_Cursor; if (isset($Result[$this->_Cursor])) { return $Result[$this->_Cursor]; } return $this->_EOF; }
[ "public", "function", "&", "PreviousRow", "(", "$", "DatasetType", "=", "FALSE", ")", "{", "$", "Result", "=", "&", "$", "this", "->", "Result", "(", "$", "DatasetType", ")", ";", "--", "$", "this", "->", "_Cursor", ";", "if", "(", "isset", "(", "$", "Result", "[", "$", "this", "->", "_Cursor", "]", ")", ")", "{", "return", "$", "Result", "[", "$", "this", "->", "_Cursor", "]", ";", "}", "return", "$", "this", "->", "_EOF", ";", "}" ]
Returns the previous row in the requested format. @param string $DatasetType The format in which the result should be returned: object or array.
[ "Returns", "the", "previous", "row", "in", "the", "requested", "format", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/database/class.dataset.php#L460-L467
7,186
bishopb/vanilla
library/database/class.dataset.php
Gdn_DataSet.&
public function &Row($RowIndex) { $Result = &$this->Result(); if(isset($Result[$RowIndex])) return $Result[$RowIndex]; return $this->_EOF; }
php
public function &Row($RowIndex) { $Result = &$this->Result(); if(isset($Result[$RowIndex])) return $Result[$RowIndex]; return $this->_EOF; }
[ "public", "function", "&", "Row", "(", "$", "RowIndex", ")", "{", "$", "Result", "=", "&", "$", "this", "->", "Result", "(", ")", ";", "if", "(", "isset", "(", "$", "Result", "[", "$", "RowIndex", "]", ")", ")", "return", "$", "Result", "[", "$", "RowIndex", "]", ";", "return", "$", "this", "->", "_EOF", ";", "}" ]
Returns the requested row index as the requested row type. @param int $RowIndex The row to return from the result set. It is zero-based. @return mixed The row at the given index or FALSE if there is no row at the index.
[ "Returns", "the", "requested", "row", "index", "as", "the", "requested", "row", "type", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/database/class.dataset.php#L508-L513
7,187
bishopb/vanilla
library/database/class.dataset.php
Gdn_DataSet.PDOStatement
public function PDOStatement(&$PDOStatement = FALSE) { if ($PDOStatement === FALSE) return $this->_PDOStatement; else $this->_PDOStatement = $PDOStatement; }
php
public function PDOStatement(&$PDOStatement = FALSE) { if ($PDOStatement === FALSE) return $this->_PDOStatement; else $this->_PDOStatement = $PDOStatement; }
[ "public", "function", "PDOStatement", "(", "&", "$", "PDOStatement", "=", "FALSE", ")", "{", "if", "(", "$", "PDOStatement", "===", "FALSE", ")", "return", "$", "this", "->", "_PDOStatement", ";", "else", "$", "this", "->", "_PDOStatement", "=", "$", "PDOStatement", ";", "}" ]
Assigns the pdostatement object to this object. @param PDOStatement $PDOStatement The PDO Statement Object being assigned.
[ "Assigns", "the", "pdostatement", "object", "to", "this", "object", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/database/class.dataset.php#L540-L545
7,188
bishopb/vanilla
library/database/class.dataset.php
Gdn_DataSet.Unserialize
public function Unserialize($Fields = array('Attributes', 'Data')) { $Result =& $this->Result(); $First = TRUE; foreach ($Result as $Row) { if ($First) { // Check which fields are in the dataset. foreach ($Fields as $Index => $Field) { if (GetValue($Field, $Row, FALSE) === FALSE) { unset($Fields[$Index]); } } $First = FALSE; } foreach ($Fields as $Field) { if (is_object($Row)) { if (is_string($Row->$Field)) $Row->$Field = @unserialize($Row->$Field); } else { if (is_string($Row[$Field])) $Row[$Field] = @unserialize($Row[$Field]); } } } }
php
public function Unserialize($Fields = array('Attributes', 'Data')) { $Result =& $this->Result(); $First = TRUE; foreach ($Result as $Row) { if ($First) { // Check which fields are in the dataset. foreach ($Fields as $Index => $Field) { if (GetValue($Field, $Row, FALSE) === FALSE) { unset($Fields[$Index]); } } $First = FALSE; } foreach ($Fields as $Field) { if (is_object($Row)) { if (is_string($Row->$Field)) $Row->$Field = @unserialize($Row->$Field); } else { if (is_string($Row[$Field])) $Row[$Field] = @unserialize($Row[$Field]); } } } }
[ "public", "function", "Unserialize", "(", "$", "Fields", "=", "array", "(", "'Attributes'", ",", "'Data'", ")", ")", "{", "$", "Result", "=", "&", "$", "this", "->", "Result", "(", ")", ";", "$", "First", "=", "TRUE", ";", "foreach", "(", "$", "Result", "as", "$", "Row", ")", "{", "if", "(", "$", "First", ")", "{", "// Check which fields are in the dataset.", "foreach", "(", "$", "Fields", "as", "$", "Index", "=>", "$", "Field", ")", "{", "if", "(", "GetValue", "(", "$", "Field", ",", "$", "Row", ",", "FALSE", ")", "===", "FALSE", ")", "{", "unset", "(", "$", "Fields", "[", "$", "Index", "]", ")", ";", "}", "}", "$", "First", "=", "FALSE", ";", "}", "foreach", "(", "$", "Fields", "as", "$", "Field", ")", "{", "if", "(", "is_object", "(", "$", "Row", ")", ")", "{", "if", "(", "is_string", "(", "$", "Row", "->", "$", "Field", ")", ")", "$", "Row", "->", "$", "Field", "=", "@", "unserialize", "(", "$", "Row", "->", "$", "Field", ")", ";", "}", "else", "{", "if", "(", "is_string", "(", "$", "Row", "[", "$", "Field", "]", ")", ")", "$", "Row", "[", "$", "Field", "]", "=", "@", "unserialize", "(", "$", "Row", "[", "$", "Field", "]", ")", ";", "}", "}", "}", "}" ]
Unserialize the fields in the dataset. @param array $Fields @since 2.1
[ "Unserialize", "the", "fields", "in", "the", "dataset", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/database/class.dataset.php#L552-L577
7,189
bishopb/vanilla
library/database/class.dataset.php
Gdn_DataSet.Value
public function Value($ColumnName, $DefaultValue = NULL) { if($Row = $this->NextRow()) { if(is_array($ColumnName)) { $Result = array(); foreach($ColumnName as $Name => $Default) { if(is_object($Row) && property_exists($Row, $Name)) return $Row->$Name; elseif(is_array($Row) && array_key_exists($Name, $Row)) return $Row[$Name]; else $Result[] = $Default; } return $Result; } else { if(is_object($Row) && property_exists($Row, $ColumnName)) return $Row->$ColumnName; elseif(is_array($Row) && array_key_exists($ColumnName, $Row)) return $Row[$ColumnName]; } } if(is_array($ColumnName)) return array_values($ColumnName); return $DefaultValue; }
php
public function Value($ColumnName, $DefaultValue = NULL) { if($Row = $this->NextRow()) { if(is_array($ColumnName)) { $Result = array(); foreach($ColumnName as $Name => $Default) { if(is_object($Row) && property_exists($Row, $Name)) return $Row->$Name; elseif(is_array($Row) && array_key_exists($Name, $Row)) return $Row[$Name]; else $Result[] = $Default; } return $Result; } else { if(is_object($Row) && property_exists($Row, $ColumnName)) return $Row->$ColumnName; elseif(is_array($Row) && array_key_exists($ColumnName, $Row)) return $Row[$ColumnName]; } } if(is_array($ColumnName)) return array_values($ColumnName); return $DefaultValue; }
[ "public", "function", "Value", "(", "$", "ColumnName", ",", "$", "DefaultValue", "=", "NULL", ")", "{", "if", "(", "$", "Row", "=", "$", "this", "->", "NextRow", "(", ")", ")", "{", "if", "(", "is_array", "(", "$", "ColumnName", ")", ")", "{", "$", "Result", "=", "array", "(", ")", ";", "foreach", "(", "$", "ColumnName", "as", "$", "Name", "=>", "$", "Default", ")", "{", "if", "(", "is_object", "(", "$", "Row", ")", "&&", "property_exists", "(", "$", "Row", ",", "$", "Name", ")", ")", "return", "$", "Row", "->", "$", "Name", ";", "elseif", "(", "is_array", "(", "$", "Row", ")", "&&", "array_key_exists", "(", "$", "Name", ",", "$", "Row", ")", ")", "return", "$", "Row", "[", "$", "Name", "]", ";", "else", "$", "Result", "[", "]", "=", "$", "Default", ";", "}", "return", "$", "Result", ";", "}", "else", "{", "if", "(", "is_object", "(", "$", "Row", ")", "&&", "property_exists", "(", "$", "Row", ",", "$", "ColumnName", ")", ")", "return", "$", "Row", "->", "$", "ColumnName", ";", "elseif", "(", "is_array", "(", "$", "Row", ")", "&&", "array_key_exists", "(", "$", "ColumnName", ",", "$", "Row", ")", ")", "return", "$", "Row", "[", "$", "ColumnName", "]", ";", "}", "}", "if", "(", "is_array", "(", "$", "ColumnName", ")", ")", "return", "array_values", "(", "$", "ColumnName", ")", ";", "return", "$", "DefaultValue", ";", "}" ]
Advances to the next row and returns the value rom a column. @param string $ColumnName The name of the column to get the value from. @param string $DefaultValue The value to return if there is no data. @return mixed The value from the column or $DefaultValue.
[ "Advances", "to", "the", "next", "row", "and", "returns", "the", "value", "rom", "a", "column", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/database/class.dataset.php#L586-L609
7,190
netcore/translations
src/Router.php
Router.apiRoutes
public static function apiRoutes(\Illuminate\Routing\Router $router) { $router->group(['prefix' => 'translations'], function (\Illuminate\Routing\Router $router) { $router->get('/index', [ 'as' => 'translations.api.index', 'uses' => ApiController::class . '@index' ]); }); }
php
public static function apiRoutes(\Illuminate\Routing\Router $router) { $router->group(['prefix' => 'translations'], function (\Illuminate\Routing\Router $router) { $router->get('/index', [ 'as' => 'translations.api.index', 'uses' => ApiController::class . '@index' ]); }); }
[ "public", "static", "function", "apiRoutes", "(", "\\", "Illuminate", "\\", "Routing", "\\", "Router", "$", "router", ")", "{", "$", "router", "->", "group", "(", "[", "'prefix'", "=>", "'translations'", "]", ",", "function", "(", "\\", "Illuminate", "\\", "Routing", "\\", "Router", "$", "router", ")", "{", "$", "router", "->", "get", "(", "'/index'", ",", "[", "'as'", "=>", "'translations.api.index'", ",", "'uses'", "=>", "ApiController", "::", "class", ".", "'@index'", "]", ")", ";", "}", ")", ";", "}" ]
Register API routes @return void
[ "Register", "API", "routes" ]
0f0c8d8b4748ee161921bfdc30683391c4fe7d7e
https://github.com/netcore/translations/blob/0f0c8d8b4748ee161921bfdc30683391c4fe7d7e/src/Router.php#L15-L24
7,191
netcore/translations
src/Router.php
Router.adminRoutes
public static function adminRoutes(\Illuminate\Routing\Router $router) { $router->group(['prefix' => 'translations'], function (\Illuminate\Routing\Router $router) { $router->get('/export', [ 'as' => 'translations.export', 'uses' => TranslationsController::class . '@export' ]); $router->post('/import', [ 'as' => 'translations.import', 'uses' => TranslationsController::class . '@import' ]); $router->post('/edit/{group}', [ 'as' => 'translations.edit', 'uses' => TranslationsController::class . '@edit' ]); $router->get('/manual', [ 'as' => 'translations.manual', 'uses' => TranslationsController::class . '@manual' ]); $router->post('/store', [ 'as' => 'translations.store', 'uses' => TranslationsController::class . '@storeTranslation' ]); $router->get('/{group?}', [ 'as' => 'translations.index', 'uses' => TranslationsController::class . '@index' ]); }); $router->resources([ 'languages' => LanguagesController::class ]); }
php
public static function adminRoutes(\Illuminate\Routing\Router $router) { $router->group(['prefix' => 'translations'], function (\Illuminate\Routing\Router $router) { $router->get('/export', [ 'as' => 'translations.export', 'uses' => TranslationsController::class . '@export' ]); $router->post('/import', [ 'as' => 'translations.import', 'uses' => TranslationsController::class . '@import' ]); $router->post('/edit/{group}', [ 'as' => 'translations.edit', 'uses' => TranslationsController::class . '@edit' ]); $router->get('/manual', [ 'as' => 'translations.manual', 'uses' => TranslationsController::class . '@manual' ]); $router->post('/store', [ 'as' => 'translations.store', 'uses' => TranslationsController::class . '@storeTranslation' ]); $router->get('/{group?}', [ 'as' => 'translations.index', 'uses' => TranslationsController::class . '@index' ]); }); $router->resources([ 'languages' => LanguagesController::class ]); }
[ "public", "static", "function", "adminRoutes", "(", "\\", "Illuminate", "\\", "Routing", "\\", "Router", "$", "router", ")", "{", "$", "router", "->", "group", "(", "[", "'prefix'", "=>", "'translations'", "]", ",", "function", "(", "\\", "Illuminate", "\\", "Routing", "\\", "Router", "$", "router", ")", "{", "$", "router", "->", "get", "(", "'/export'", ",", "[", "'as'", "=>", "'translations.export'", ",", "'uses'", "=>", "TranslationsController", "::", "class", ".", "'@export'", "]", ")", ";", "$", "router", "->", "post", "(", "'/import'", ",", "[", "'as'", "=>", "'translations.import'", ",", "'uses'", "=>", "TranslationsController", "::", "class", ".", "'@import'", "]", ")", ";", "$", "router", "->", "post", "(", "'/edit/{group}'", ",", "[", "'as'", "=>", "'translations.edit'", ",", "'uses'", "=>", "TranslationsController", "::", "class", ".", "'@edit'", "]", ")", ";", "$", "router", "->", "get", "(", "'/manual'", ",", "[", "'as'", "=>", "'translations.manual'", ",", "'uses'", "=>", "TranslationsController", "::", "class", ".", "'@manual'", "]", ")", ";", "$", "router", "->", "post", "(", "'/store'", ",", "[", "'as'", "=>", "'translations.store'", ",", "'uses'", "=>", "TranslationsController", "::", "class", ".", "'@storeTranslation'", "]", ")", ";", "$", "router", "->", "get", "(", "'/{group?}'", ",", "[", "'as'", "=>", "'translations.index'", ",", "'uses'", "=>", "TranslationsController", "::", "class", ".", "'@index'", "]", ")", ";", "}", ")", ";", "$", "router", "->", "resources", "(", "[", "'languages'", "=>", "LanguagesController", "::", "class", "]", ")", ";", "}" ]
Register admin routes @return void
[ "Register", "admin", "routes" ]
0f0c8d8b4748ee161921bfdc30683391c4fe7d7e
https://github.com/netcore/translations/blob/0f0c8d8b4748ee161921bfdc30683391c4fe7d7e/src/Router.php#L31-L70
7,192
freialib/fenrir.tools
src/Pdx.php
Pdx.rm
function rm($dryrun = false, $harduninstall = false) { if ($this->locked) { return [null, 400]; } else { // database is not locked $channels = $this->channels(); $config = [ 'tables' => [] ]; if ( ! $harduninstall) { list($history) = $this->history(); // generate table list based on history foreach ($history as $i) { if ($i['hotfix'] === null) { $handlers = $channels[$i['channel']]['versions'][$i['version']]; } else { // hotfix $handlers = $channels[$i['channel']]['versions'][$i['version']]['hotfixes'][$i['hotfix']]; } $this->rm__load_tables($config, $handlers); } } else { // hard uninstall foreach ($channels as $channelname => $chaninfo) { foreach ($chaninfo['versions'] as $version => $handlers) { $this->rm__load_tables($config, $handlers); if (isset($handlers['hotfixes'])) { foreach ($handlers['hotfixes'] as $hotfix => $fixhandlers) { $this->rm__load_tables($config, $fixhandlers); } } } } } if ($this->has_history_table()) { $config['tables'][] = $this->table(); } if ($dryrun) { return [$config['tables'], 0]; } if ( ! empty($config['tables'])) { $dbh = $this->dbh(); $dbh->prepare('SET foreign_key_checks = FALSE') ->execute(); foreach ($config['tables'] as $table) { $this->log(" Removing $table\n"); $dbh->prepare("DROP TABLE IF EXISTS `$table`") ->execute(); } $dbh->prepare('SET foreign_key_checks = TRUE') ->execute(); } else { // empty tables $this->log("Nothing to remove.\n"); } } return [null, 0]; }
php
function rm($dryrun = false, $harduninstall = false) { if ($this->locked) { return [null, 400]; } else { // database is not locked $channels = $this->channels(); $config = [ 'tables' => [] ]; if ( ! $harduninstall) { list($history) = $this->history(); // generate table list based on history foreach ($history as $i) { if ($i['hotfix'] === null) { $handlers = $channels[$i['channel']]['versions'][$i['version']]; } else { // hotfix $handlers = $channels[$i['channel']]['versions'][$i['version']]['hotfixes'][$i['hotfix']]; } $this->rm__load_tables($config, $handlers); } } else { // hard uninstall foreach ($channels as $channelname => $chaninfo) { foreach ($chaninfo['versions'] as $version => $handlers) { $this->rm__load_tables($config, $handlers); if (isset($handlers['hotfixes'])) { foreach ($handlers['hotfixes'] as $hotfix => $fixhandlers) { $this->rm__load_tables($config, $fixhandlers); } } } } } if ($this->has_history_table()) { $config['tables'][] = $this->table(); } if ($dryrun) { return [$config['tables'], 0]; } if ( ! empty($config['tables'])) { $dbh = $this->dbh(); $dbh->prepare('SET foreign_key_checks = FALSE') ->execute(); foreach ($config['tables'] as $table) { $this->log(" Removing $table\n"); $dbh->prepare("DROP TABLE IF EXISTS `$table`") ->execute(); } $dbh->prepare('SET foreign_key_checks = TRUE') ->execute(); } else { // empty tables $this->log("Nothing to remove.\n"); } } return [null, 0]; }
[ "function", "rm", "(", "$", "dryrun", "=", "false", ",", "$", "harduninstall", "=", "false", ")", "{", "if", "(", "$", "this", "->", "locked", ")", "{", "return", "[", "null", ",", "400", "]", ";", "}", "else", "{", "// database is not locked", "$", "channels", "=", "$", "this", "->", "channels", "(", ")", ";", "$", "config", "=", "[", "'tables'", "=>", "[", "]", "]", ";", "if", "(", "!", "$", "harduninstall", ")", "{", "list", "(", "$", "history", ")", "=", "$", "this", "->", "history", "(", ")", ";", "// generate table list based on history", "foreach", "(", "$", "history", "as", "$", "i", ")", "{", "if", "(", "$", "i", "[", "'hotfix'", "]", "===", "null", ")", "{", "$", "handlers", "=", "$", "channels", "[", "$", "i", "[", "'channel'", "]", "]", "[", "'versions'", "]", "[", "$", "i", "[", "'version'", "]", "]", ";", "}", "else", "{", "// hotfix", "$", "handlers", "=", "$", "channels", "[", "$", "i", "[", "'channel'", "]", "]", "[", "'versions'", "]", "[", "$", "i", "[", "'version'", "]", "]", "[", "'hotfixes'", "]", "[", "$", "i", "[", "'hotfix'", "]", "]", ";", "}", "$", "this", "->", "rm__load_tables", "(", "$", "config", ",", "$", "handlers", ")", ";", "}", "}", "else", "{", "// hard uninstall", "foreach", "(", "$", "channels", "as", "$", "channelname", "=>", "$", "chaninfo", ")", "{", "foreach", "(", "$", "chaninfo", "[", "'versions'", "]", "as", "$", "version", "=>", "$", "handlers", ")", "{", "$", "this", "->", "rm__load_tables", "(", "$", "config", ",", "$", "handlers", ")", ";", "if", "(", "isset", "(", "$", "handlers", "[", "'hotfixes'", "]", ")", ")", "{", "foreach", "(", "$", "handlers", "[", "'hotfixes'", "]", "as", "$", "hotfix", "=>", "$", "fixhandlers", ")", "{", "$", "this", "->", "rm__load_tables", "(", "$", "config", ",", "$", "fixhandlers", ")", ";", "}", "}", "}", "}", "}", "if", "(", "$", "this", "->", "has_history_table", "(", ")", ")", "{", "$", "config", "[", "'tables'", "]", "[", "]", "=", "$", "this", "->", "table", "(", ")", ";", "}", "if", "(", "$", "dryrun", ")", "{", "return", "[", "$", "config", "[", "'tables'", "]", ",", "0", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "config", "[", "'tables'", "]", ")", ")", "{", "$", "dbh", "=", "$", "this", "->", "dbh", "(", ")", ";", "$", "dbh", "->", "prepare", "(", "'SET foreign_key_checks = FALSE'", ")", "->", "execute", "(", ")", ";", "foreach", "(", "$", "config", "[", "'tables'", "]", "as", "$", "table", ")", "{", "$", "this", "->", "log", "(", "\" Removing $table\\n\"", ")", ";", "$", "dbh", "->", "prepare", "(", "\"DROP TABLE IF EXISTS `$table`\"", ")", "->", "execute", "(", ")", ";", "}", "$", "dbh", "->", "prepare", "(", "'SET foreign_key_checks = TRUE'", ")", "->", "execute", "(", ")", ";", "}", "else", "{", "// empty tables", "$", "this", "->", "log", "(", "\"Nothing to remove.\\n\"", ")", ";", "}", "}", "return", "[", "null", ",", "0", "]", ";", "}" ]
Removes all tables. @return boolean true if successful, false if not permitted
[ "Removes", "all", "tables", "." ]
3e6359103a640bd2fcb9708d6874fb0aeebbf7c5
https://github.com/freialib/fenrir.tools/blob/3e6359103a640bd2fcb9708d6874fb0aeebbf7c5/src/Pdx.php#L278-L345
7,193
freialib/fenrir.tools
src/Pdx.php
Pdx.sync
function sync($dryrun = false) { $channels = $this->channels(); $status = [ // ordered list of versions in processing order 'history' => [], // current version for each channel 'state' => [], // active channels 'active' => [], // checklist of version requirements 'checklist' => $this->generate_checklist($channels) ]; // inject current history list($history, $err) = $this->history(); if ($err !== 0) { throw new Panic('Failed to retrieve history.'); } foreach ($history as $entry) { if ($entry['hotfix'] === null) { $status['state'][$entry['channel']] = $this->binversion($entry['channel'], $entry['version']); } } // generate version history for upgrade foreach ($channels as $channel => &$timeline) { if (count($timeline['versions']) > 0) { end($timeline['versions']); $last_version = key($timeline['versions']); $this->processhistory($channel, $last_version, $status, $channels); } } // dry run? if ($dryrun) { // just return the step history return [$status['history'], 0]; } $migrations = 0; if ( ! empty($status['history'])) { // execute the history foreach ($status['history'] as $entry) { // execute migration $this->processmigration($channels, $entry['channel'], $entry['version'], $entry['hotfix']); $migrations++; } } else { // no history $this->log("No changes required.\n"); return [$migrations, 0]; } // operation complete return [$migrations, 0]; }
php
function sync($dryrun = false) { $channels = $this->channels(); $status = [ // ordered list of versions in processing order 'history' => [], // current version for each channel 'state' => [], // active channels 'active' => [], // checklist of version requirements 'checklist' => $this->generate_checklist($channels) ]; // inject current history list($history, $err) = $this->history(); if ($err !== 0) { throw new Panic('Failed to retrieve history.'); } foreach ($history as $entry) { if ($entry['hotfix'] === null) { $status['state'][$entry['channel']] = $this->binversion($entry['channel'], $entry['version']); } } // generate version history for upgrade foreach ($channels as $channel => &$timeline) { if (count($timeline['versions']) > 0) { end($timeline['versions']); $last_version = key($timeline['versions']); $this->processhistory($channel, $last_version, $status, $channels); } } // dry run? if ($dryrun) { // just return the step history return [$status['history'], 0]; } $migrations = 0; if ( ! empty($status['history'])) { // execute the history foreach ($status['history'] as $entry) { // execute migration $this->processmigration($channels, $entry['channel'], $entry['version'], $entry['hotfix']); $migrations++; } } else { // no history $this->log("No changes required.\n"); return [$migrations, 0]; } // operation complete return [$migrations, 0]; }
[ "function", "sync", "(", "$", "dryrun", "=", "false", ")", "{", "$", "channels", "=", "$", "this", "->", "channels", "(", ")", ";", "$", "status", "=", "[", "// ordered list of versions in processing order", "'history'", "=>", "[", "]", ",", "// current version for each channel", "'state'", "=>", "[", "]", ",", "// active channels", "'active'", "=>", "[", "]", ",", "// checklist of version requirements", "'checklist'", "=>", "$", "this", "->", "generate_checklist", "(", "$", "channels", ")", "]", ";", "// inject current history", "list", "(", "$", "history", ",", "$", "err", ")", "=", "$", "this", "->", "history", "(", ")", ";", "if", "(", "$", "err", "!==", "0", ")", "{", "throw", "new", "Panic", "(", "'Failed to retrieve history.'", ")", ";", "}", "foreach", "(", "$", "history", "as", "$", "entry", ")", "{", "if", "(", "$", "entry", "[", "'hotfix'", "]", "===", "null", ")", "{", "$", "status", "[", "'state'", "]", "[", "$", "entry", "[", "'channel'", "]", "]", "=", "$", "this", "->", "binversion", "(", "$", "entry", "[", "'channel'", "]", ",", "$", "entry", "[", "'version'", "]", ")", ";", "}", "}", "// generate version history for upgrade", "foreach", "(", "$", "channels", "as", "$", "channel", "=>", "&", "$", "timeline", ")", "{", "if", "(", "count", "(", "$", "timeline", "[", "'versions'", "]", ")", ">", "0", ")", "{", "end", "(", "$", "timeline", "[", "'versions'", "]", ")", ";", "$", "last_version", "=", "key", "(", "$", "timeline", "[", "'versions'", "]", ")", ";", "$", "this", "->", "processhistory", "(", "$", "channel", ",", "$", "last_version", ",", "$", "status", ",", "$", "channels", ")", ";", "}", "}", "// dry run?", "if", "(", "$", "dryrun", ")", "{", "// just return the step history", "return", "[", "$", "status", "[", "'history'", "]", ",", "0", "]", ";", "}", "$", "migrations", "=", "0", ";", "if", "(", "!", "empty", "(", "$", "status", "[", "'history'", "]", ")", ")", "{", "// execute the history", "foreach", "(", "$", "status", "[", "'history'", "]", "as", "$", "entry", ")", "{", "// execute migration", "$", "this", "->", "processmigration", "(", "$", "channels", ",", "$", "entry", "[", "'channel'", "]", ",", "$", "entry", "[", "'version'", "]", ",", "$", "entry", "[", "'hotfix'", "]", ")", ";", "$", "migrations", "++", ";", "}", "}", "else", "{", "// no history", "$", "this", "->", "log", "(", "\"No changes required.\\n\"", ")", ";", "return", "[", "$", "migrations", ",", "0", "]", ";", "}", "// operation complete", "return", "[", "$", "migrations", ",", "0", "]", ";", "}" ]
Move the database forward.
[ "Move", "the", "database", "forward", "." ]
3e6359103a640bd2fcb9708d6874fb0aeebbf7c5
https://github.com/freialib/fenrir.tools/blob/3e6359103a640bd2fcb9708d6874fb0aeebbf7c5/src/Pdx.php#L350-L410
7,194
freialib/fenrir.tools
src/Pdx.php
Pdx.conf
protected function conf($confpath, $dependencies = []) { $conf = $this->confs->read($confpath); if (isset($conf['require'])) { throw new Panic("The paradox configuration $confpath must not contain a require key. Only the main paradox configuration should specify dependencies."); } return array_merge($conf, [ 'require' => $dependencies ]); }
php
protected function conf($confpath, $dependencies = []) { $conf = $this->confs->read($confpath); if (isset($conf['require'])) { throw new Panic("The paradox configuration $confpath must not contain a require key. Only the main paradox configuration should specify dependencies."); } return array_merge($conf, [ 'require' => $dependencies ]); }
[ "protected", "function", "conf", "(", "$", "confpath", ",", "$", "dependencies", "=", "[", "]", ")", "{", "$", "conf", "=", "$", "this", "->", "confs", "->", "read", "(", "$", "confpath", ")", ";", "if", "(", "isset", "(", "$", "conf", "[", "'require'", "]", ")", ")", "{", "throw", "new", "Panic", "(", "\"The paradox configuration $confpath must not contain a require key. Only the main paradox configuration should specify dependencies.\"", ")", ";", "}", "return", "array_merge", "(", "$", "conf", ",", "[", "'require'", "=>", "$", "dependencies", "]", ")", ";", "}" ]
Normalize configuration entry @return array
[ "Normalize", "configuration", "entry" ]
3e6359103a640bd2fcb9708d6874fb0aeebbf7c5
https://github.com/freialib/fenrir.tools/blob/3e6359103a640bd2fcb9708d6874fb0aeebbf7c5/src/Pdx.php#L433-L442
7,195
freialib/fenrir.tools
src/Pdx.php
Pdx.shout
protected function shout($op, $channel, $version, $note = null) { ! $this->verbose or $this->log(sprintf($this->step_format()."\n", $op, $version, $channel, $note)); return true; // allow use in shorthand conditionals }
php
protected function shout($op, $channel, $version, $note = null) { ! $this->verbose or $this->log(sprintf($this->step_format()."\n", $op, $version, $channel, $note)); return true; // allow use in shorthand conditionals }
[ "protected", "function", "shout", "(", "$", "op", ",", "$", "channel", ",", "$", "version", ",", "$", "note", "=", "null", ")", "{", "!", "$", "this", "->", "verbose", "or", "$", "this", "->", "log", "(", "sprintf", "(", "$", "this", "->", "step_format", "(", ")", ".", "\"\\n\"", ",", "$", "op", ",", "$", "version", ",", "$", "channel", ",", "$", "note", ")", ")", ";", "return", "true", ";", "// allow use in shorthand conditionals", "}" ]
Step information for verbose output @return boolean
[ "Step", "information", "for", "verbose", "output" ]
3e6359103a640bd2fcb9708d6874fb0aeebbf7c5
https://github.com/freialib/fenrir.tools/blob/3e6359103a640bd2fcb9708d6874fb0aeebbf7c5/src/Pdx.php#L485-L488
7,196
freialib/fenrir.tools
src/Pdx.php
Pdx.dependency_race_error
protected function dependency_race_error(array $status, $channel, $version) { // provide feedback on loop ! $this->verbose or $this->log("\n"); $this->log(" Race backtrace:\n"); foreach ($status['active'] as $activeinfo) { $this->log(" - {$activeinfo['channel']} {$activeinfo['version']}\n"); } $this->log("\n"); throw new Panic("Target version breached by race condition on $channel $version"); }
php
protected function dependency_race_error(array $status, $channel, $version) { // provide feedback on loop ! $this->verbose or $this->log("\n"); $this->log(" Race backtrace:\n"); foreach ($status['active'] as $activeinfo) { $this->log(" - {$activeinfo['channel']} {$activeinfo['version']}\n"); } $this->log("\n"); throw new Panic("Target version breached by race condition on $channel $version"); }
[ "protected", "function", "dependency_race_error", "(", "array", "$", "status", ",", "$", "channel", ",", "$", "version", ")", "{", "// provide feedback on loop", "!", "$", "this", "->", "verbose", "or", "$", "this", "->", "log", "(", "\"\\n\"", ")", ";", "$", "this", "->", "log", "(", "\" Race backtrace:\\n\"", ")", ";", "foreach", "(", "$", "status", "[", "'active'", "]", "as", "$", "activeinfo", ")", "{", "$", "this", "->", "log", "(", "\" - {$activeinfo['channel']} {$activeinfo['version']}\\n\"", ")", ";", "}", "$", "this", "->", "log", "(", "\"\\n\"", ")", ";", "throw", "new", "Panic", "(", "\"Target version breached by race condition on $channel $version\"", ")", ";", "}" ]
Error report for situation where dependencies race against each other and a channels fall behind another in the requirement war.
[ "Error", "report", "for", "situation", "where", "dependencies", "race", "against", "each", "other", "and", "a", "channels", "fall", "behind", "another", "in", "the", "requirement", "war", "." ]
3e6359103a640bd2fcb9708d6874fb0aeebbf7c5
https://github.com/freialib/fenrir.tools/blob/3e6359103a640bd2fcb9708d6874fb0aeebbf7c5/src/Pdx.php#L609-L619
7,197
freialib/fenrir.tools
src/Pdx.php
Pdx.rm__load_tables
protected function rm__load_tables(array &$config, array $handlers) { if (isset($handlers['configure'])) { $conf = $handlers['configure']; if (is_array($conf)) { if (isset($conf['tables'])) { foreach ($conf['tables'] as $table) { $config['tables'][] = $table; } } } else { // callback $config = $conf($config); } } }
php
protected function rm__load_tables(array &$config, array $handlers) { if (isset($handlers['configure'])) { $conf = $handlers['configure']; if (is_array($conf)) { if (isset($conf['tables'])) { foreach ($conf['tables'] as $table) { $config['tables'][] = $table; } } } else { // callback $config = $conf($config); } } }
[ "protected", "function", "rm__load_tables", "(", "array", "&", "$", "config", ",", "array", "$", "handlers", ")", "{", "if", "(", "isset", "(", "$", "handlers", "[", "'configure'", "]", ")", ")", "{", "$", "conf", "=", "$", "handlers", "[", "'configure'", "]", ";", "if", "(", "is_array", "(", "$", "conf", ")", ")", "{", "if", "(", "isset", "(", "$", "conf", "[", "'tables'", "]", ")", ")", "{", "foreach", "(", "$", "conf", "[", "'tables'", "]", "as", "$", "table", ")", "{", "$", "config", "[", "'tables'", "]", "[", "]", "=", "$", "table", ";", "}", "}", "}", "else", "{", "// callback", "$", "config", "=", "$", "conf", "(", "$", "config", ")", ";", "}", "}", "}" ]
Loads tables from configuration
[ "Loads", "tables", "from", "configuration" ]
3e6359103a640bd2fcb9708d6874fb0aeebbf7c5
https://github.com/freialib/fenrir.tools/blob/3e6359103a640bd2fcb9708d6874fb0aeebbf7c5/src/Pdx.php#L1000-L1014
7,198
hnhdigital-os/bluora-shared-api-traits
src/EnvironmentVariablesTrait.php
EnvironmentVariablesTrait.hasConfig
public function hasConfig($name) { if (property_exists($this, 'client_'.$name)) { $name = 'client_'.$name; return !empty($this->$name); } return false; }
php
public function hasConfig($name) { if (property_exists($this, 'client_'.$name)) { $name = 'client_'.$name; return !empty($this->$name); } return false; }
[ "public", "function", "hasConfig", "(", "$", "name", ")", "{", "if", "(", "property_exists", "(", "$", "this", ",", "'client_'", ".", "$", "name", ")", ")", "{", "$", "name", "=", "'client_'", ".", "$", "name", ";", "return", "!", "empty", "(", "$", "this", "->", "$", "name", ")", ";", "}", "return", "false", ";", "}" ]
Check if this client has been provided a property value. @param $name @return bool
[ "Check", "if", "this", "client", "has", "been", "provided", "a", "property", "value", "." ]
bf5f25e938492f5bdd05db092d84f35fc3b035ad
https://github.com/hnhdigital-os/bluora-shared-api-traits/blob/bf5f25e938492f5bdd05db092d84f35fc3b035ad/src/EnvironmentVariablesTrait.php#L39-L46
7,199
hnhdigital-os/bluora-shared-api-traits
src/EnvironmentVariablesTrait.php
EnvironmentVariablesTrait.setConfig
public function setConfig($name, $value) { if (property_exists($this, 'client_'.$name) && !empty($value)) { $name = 'client_'.$name; $this->$name = $value; } return $this; }
php
public function setConfig($name, $value) { if (property_exists($this, 'client_'.$name) && !empty($value)) { $name = 'client_'.$name; $this->$name = $value; } return $this; }
[ "public", "function", "setConfig", "(", "$", "name", ",", "$", "value", ")", "{", "if", "(", "property_exists", "(", "$", "this", ",", "'client_'", ".", "$", "name", ")", "&&", "!", "empty", "(", "$", "value", ")", ")", "{", "$", "name", "=", "'client_'", ".", "$", "name", ";", "$", "this", "->", "$", "name", "=", "$", "value", ";", "}", "return", "$", "this", ";", "}" ]
Set a config variable. @param string $name @param string $value @return IsbnPlus
[ "Set", "a", "config", "variable", "." ]
bf5f25e938492f5bdd05db092d84f35fc3b035ad
https://github.com/hnhdigital-os/bluora-shared-api-traits/blob/bf5f25e938492f5bdd05db092d84f35fc3b035ad/src/EnvironmentVariablesTrait.php#L56-L64