repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
mirko-pagliai/me-cms
src/Controller/UsersController.php
UsersController.sendActivationMail
protected function sendActivationMail($user) { //Creates the token $token = $this->Token->create($user->email, ['type' => 'signup', 'user_id' => $user->id]); return $this->getMailer('MeCms.User') ->set('url', Router::url(['_name' => 'activation', $user->id, $token], true)) ->send('activation', [$user]); }
php
protected function sendActivationMail($user) { //Creates the token $token = $this->Token->create($user->email, ['type' => 'signup', 'user_id' => $user->id]); return $this->getMailer('MeCms.User') ->set('url', Router::url(['_name' => 'activation', $user->id, $token], true)) ->send('activation', [$user]); }
[ "protected", "function", "sendActivationMail", "(", "$", "user", ")", "{", "//Creates the token", "$", "token", "=", "$", "this", "->", "Token", "->", "create", "(", "$", "user", "->", "email", ",", "[", "'type'", "=>", "'signup'", ",", "'user_id'", "=>", ...
Internal method to send the activation mail @param MeCms\Model\Entity\User $user User entity @return bool @see MeCms\Mailer\UserMailer::activation()
[ "Internal", "method", "to", "send", "the", "activation", "mail" ]
df668ad8e3ee221497c47578d474e487f24ce92a
https://github.com/mirko-pagliai/me-cms/blob/df668ad8e3ee221497c47578d474e487f24ce92a/src/Controller/UsersController.php#L81-L89
train
ommu/mod-core
models/OmmuWallComment.php
OmmuWallComment.getGridColumn
public function getGridColumn($columns=null) { if($columns !== null) { foreach($columns as $val) { /* if(trim($val) == 'enabled') { $this->defaultColumns[] = array( 'name' => 'enabled', 'value' => '$data->enabled == 1? "Ya": "Tidak"', ); } */ $this->defaultColumns[] = $val; } } else { //$this->defaultColumns[] = 'comment_id'; $this->defaultColumns[] = 'publish'; $this->defaultColumns[] = 'parent_id'; $this->defaultColumns[] = 'wall_id'; $this->defaultColumns[] = 'user_id'; $this->defaultColumns[] = 'comment'; $this->defaultColumns[] = 'creation_date'; $this->defaultColumns[] = 'modified_date'; } return $this->defaultColumns; }
php
public function getGridColumn($columns=null) { if($columns !== null) { foreach($columns as $val) { /* if(trim($val) == 'enabled') { $this->defaultColumns[] = array( 'name' => 'enabled', 'value' => '$data->enabled == 1? "Ya": "Tidak"', ); } */ $this->defaultColumns[] = $val; } } else { //$this->defaultColumns[] = 'comment_id'; $this->defaultColumns[] = 'publish'; $this->defaultColumns[] = 'parent_id'; $this->defaultColumns[] = 'wall_id'; $this->defaultColumns[] = 'user_id'; $this->defaultColumns[] = 'comment'; $this->defaultColumns[] = 'creation_date'; $this->defaultColumns[] = 'modified_date'; } return $this->defaultColumns; }
[ "public", "function", "getGridColumn", "(", "$", "columns", "=", "null", ")", "{", "if", "(", "$", "columns", "!==", "null", ")", "{", "foreach", "(", "$", "columns", "as", "$", "val", ")", "{", "/*\r\n\t\t\t\tif(trim($val) == 'enabled') {\r\n\t\t\t\t\t$this->de...
Get column for CGrid View
[ "Get", "column", "for", "CGrid", "View" ]
68c90e76440e74ee93bcf82905a54d86c941b771
https://github.com/ommu/mod-core/blob/68c90e76440e74ee93bcf82905a54d86c941b771/models/OmmuWallComment.php#L193-L218
train
nails/module-console
src/App.php
App.go
public function go( $sEntryPoint, InputInterface $oInputInterface = null, OutputInterface $oOutputInterface = null, $bAutoExit = true ) { /* *--------------------------------------------------------------- * App Bootstrapper: preSystem *--------------------------------------------------------------- * Allows the app to execute code very early on in the console tool lifecycle */ if (class_exists('\App\Console\Bootstrap') && is_callable('\App\Console\Bootstrap::preSystem')) { \App\Console\Bootstrap::preSystem($this); } /* *--------------------------------------------------------------- * Nails Bootstrapper *--------------------------------------------------------------- */ \Nails\Bootstrap::run($sEntryPoint); /* *--------------------------------------------------------------- * Command line can run forever *--------------------------------------------------------------- */ set_time_limit(0); /* *--------------------------------------------------------------- * Instantiate CI's Utf8 library; so we have the appropriate * constants defined *--------------------------------------------------------------- */ $oUtf8 = new Utf8(); /* *--------------------------------------------------------------- * CLI only *--------------------------------------------------------------- */ $oInput = Factory::service('Input'); if (!$oInput::isCli()) { ErrorHandler::halt('This tool can only be used on the command line.'); } /* *--------------------------------------------------------------- * Instantiate the application *--------------------------------------------------------------- */ $oApp = new Application(); /* *--------------------------------------------------------------- * Set auto-exit behaviour *--------------------------------------------------------------- */ $oApp->setAutoExit($bAutoExit); /* *--------------------------------------------------------------- * Command Locations *--------------------------------------------------------------- * Define which directories to look in for Console Commands */ $aCommandLocations = [ [NAILS_APP_PATH . 'vendor/nails/common/src/Common/Console/Command/', 'Nails\Common\Console\Command'], [NAILS_APP_PATH . 'src/Console/Command/', 'App\Console\Command'], ]; $aModules = Components::modules(); foreach ($aModules as $oModule) { $aCommandLocations[] = [ $oModule->path . 'src/Console/Command', $oModule->namespace . 'Console\Command', ]; } /* *--------------------------------------------------------------- * Load Commands *--------------------------------------------------------------- * Recursively look for commands */ Factory::helper('directory'); $aCommands = []; function findCommands(&$aCommands, $sPath, $sNamespace) { $aDirMap = directory_map($sPath); if (!empty($aDirMap)) { foreach ($aDirMap as $sDir => $sFile) { if (is_array($sFile)) { findCommands($aCommands, $sPath . DIRECTORY_SEPARATOR . $sDir, $sNamespace . '\\' . trim($sDir, '/')); } else { $aFileInfo = pathinfo($sFile); $sFileName = basename($sFile, '.' . $aFileInfo['extension']); $aCommands[] = $sNamespace . '\\' . $sFileName; } } } } foreach ($aCommandLocations as $aLocation) { list($sPath, $sNamespace) = $aLocation; findCommands($aCommands, $sPath, $sNamespace); } foreach ($aCommands as $sCommandClass) { $oApp->add(new $sCommandClass()); } /* *--------------------------------------------------------------- * App Bootstrapper: preCommand *--------------------------------------------------------------- * Allows the app to execute code just before the command is called */ if (class_exists('\App\Console\Bootstrap') && is_callable('\App\Console\Bootstrap::preCommand')) { \App\Console\Bootstrap::preCommand($this); } /* *--------------------------------------------------------------- * Run the application *--------------------------------------------------------------- * Go, go, go! */ $oApp->run($oInputInterface, $oOutputInterface); /* *--------------------------------------------------------------- * App Bootstrapper: postCommand *--------------------------------------------------------------- * Allows the app to execute code just after the command is called */ if (class_exists('\App\Console\Bootstrap') && is_callable('\App\Console\Bootstrap::postCommand')) { \App\Console\Bootstrap::postCommand($this); } /* *--------------------------------------------------------------- * Nails Shotdown Handler *--------------------------------------------------------------- */ \Nails\Bootstrap::shutdown(); /* *--------------------------------------------------------------- * App Bootstrapper: postSystem *--------------------------------------------------------------- * Allows the app to execute code at the very end of the console tool lifecycle */ if (class_exists('\App\Console\Bootstrap') && is_callable('\App\Console\Bootstrap::postSystem')) { \App\Console\Bootstrap::postSystem($this); } }
php
public function go( $sEntryPoint, InputInterface $oInputInterface = null, OutputInterface $oOutputInterface = null, $bAutoExit = true ) { /* *--------------------------------------------------------------- * App Bootstrapper: preSystem *--------------------------------------------------------------- * Allows the app to execute code very early on in the console tool lifecycle */ if (class_exists('\App\Console\Bootstrap') && is_callable('\App\Console\Bootstrap::preSystem')) { \App\Console\Bootstrap::preSystem($this); } /* *--------------------------------------------------------------- * Nails Bootstrapper *--------------------------------------------------------------- */ \Nails\Bootstrap::run($sEntryPoint); /* *--------------------------------------------------------------- * Command line can run forever *--------------------------------------------------------------- */ set_time_limit(0); /* *--------------------------------------------------------------- * Instantiate CI's Utf8 library; so we have the appropriate * constants defined *--------------------------------------------------------------- */ $oUtf8 = new Utf8(); /* *--------------------------------------------------------------- * CLI only *--------------------------------------------------------------- */ $oInput = Factory::service('Input'); if (!$oInput::isCli()) { ErrorHandler::halt('This tool can only be used on the command line.'); } /* *--------------------------------------------------------------- * Instantiate the application *--------------------------------------------------------------- */ $oApp = new Application(); /* *--------------------------------------------------------------- * Set auto-exit behaviour *--------------------------------------------------------------- */ $oApp->setAutoExit($bAutoExit); /* *--------------------------------------------------------------- * Command Locations *--------------------------------------------------------------- * Define which directories to look in for Console Commands */ $aCommandLocations = [ [NAILS_APP_PATH . 'vendor/nails/common/src/Common/Console/Command/', 'Nails\Common\Console\Command'], [NAILS_APP_PATH . 'src/Console/Command/', 'App\Console\Command'], ]; $aModules = Components::modules(); foreach ($aModules as $oModule) { $aCommandLocations[] = [ $oModule->path . 'src/Console/Command', $oModule->namespace . 'Console\Command', ]; } /* *--------------------------------------------------------------- * Load Commands *--------------------------------------------------------------- * Recursively look for commands */ Factory::helper('directory'); $aCommands = []; function findCommands(&$aCommands, $sPath, $sNamespace) { $aDirMap = directory_map($sPath); if (!empty($aDirMap)) { foreach ($aDirMap as $sDir => $sFile) { if (is_array($sFile)) { findCommands($aCommands, $sPath . DIRECTORY_SEPARATOR . $sDir, $sNamespace . '\\' . trim($sDir, '/')); } else { $aFileInfo = pathinfo($sFile); $sFileName = basename($sFile, '.' . $aFileInfo['extension']); $aCommands[] = $sNamespace . '\\' . $sFileName; } } } } foreach ($aCommandLocations as $aLocation) { list($sPath, $sNamespace) = $aLocation; findCommands($aCommands, $sPath, $sNamespace); } foreach ($aCommands as $sCommandClass) { $oApp->add(new $sCommandClass()); } /* *--------------------------------------------------------------- * App Bootstrapper: preCommand *--------------------------------------------------------------- * Allows the app to execute code just before the command is called */ if (class_exists('\App\Console\Bootstrap') && is_callable('\App\Console\Bootstrap::preCommand')) { \App\Console\Bootstrap::preCommand($this); } /* *--------------------------------------------------------------- * Run the application *--------------------------------------------------------------- * Go, go, go! */ $oApp->run($oInputInterface, $oOutputInterface); /* *--------------------------------------------------------------- * App Bootstrapper: postCommand *--------------------------------------------------------------- * Allows the app to execute code just after the command is called */ if (class_exists('\App\Console\Bootstrap') && is_callable('\App\Console\Bootstrap::postCommand')) { \App\Console\Bootstrap::postCommand($this); } /* *--------------------------------------------------------------- * Nails Shotdown Handler *--------------------------------------------------------------- */ \Nails\Bootstrap::shutdown(); /* *--------------------------------------------------------------- * App Bootstrapper: postSystem *--------------------------------------------------------------- * Allows the app to execute code at the very end of the console tool lifecycle */ if (class_exists('\App\Console\Bootstrap') && is_callable('\App\Console\Bootstrap::postSystem')) { \App\Console\Bootstrap::postSystem($this); } }
[ "public", "function", "go", "(", "$", "sEntryPoint", ",", "InputInterface", "$", "oInputInterface", "=", "null", ",", "OutputInterface", "$", "oOutputInterface", "=", "null", ",", "$", "bAutoExit", "=", "true", ")", "{", "/*\n *------------------------------...
Executes the console app @param string $sEntryPoint The path of the route index.php file @param InputInterface|null $oInputInterface The input interface to use @param OutputInterface|null $oOutputInterface The output interface to use @param bool $bAutoExit Whether to auto-exit from the application or not @throws \Nails\Common\Exception\FactoryException
[ "Executes", "the", "console", "app" ]
bef013213c914af33172293a386e2738ceedc12d
https://github.com/nails/module-console/blob/bef013213c914af33172293a386e2738ceedc12d/src/App.php#L25-L199
train
mirko-pagliai/cakephp-recaptcha-mailhide
src/View/Helper/MailhideHelper.php
MailhideHelper.obfuscate
protected function obfuscate($mail) { return preg_replace_callback('/^([^@]+)(.*)$/', function ($matches) { $lenght = floor(strlen($matches[1]) / 2); $name = substr($matches[1], 0, $lenght) . str_repeat('*', $lenght); return $name . $matches[2]; }, $mail); }
php
protected function obfuscate($mail) { return preg_replace_callback('/^([^@]+)(.*)$/', function ($matches) { $lenght = floor(strlen($matches[1]) / 2); $name = substr($matches[1], 0, $lenght) . str_repeat('*', $lenght); return $name . $matches[2]; }, $mail); }
[ "protected", "function", "obfuscate", "(", "$", "mail", ")", "{", "return", "preg_replace_callback", "(", "'/^([^@]+)(.*)$/'", ",", "function", "(", "$", "matches", ")", "{", "$", "lenght", "=", "floor", "(", "strlen", "(", "$", "matches", "[", "1", "]", ...
Internal method to obfuscate an email address @param string $mail Mail address @return string
[ "Internal", "method", "to", "obfuscate", "an", "email", "address" ]
d3a9acaea5382b20cd36f794d75265337d5cb3ac
https://github.com/mirko-pagliai/cakephp-recaptcha-mailhide/blob/d3a9acaea5382b20cd36f794d75265337d5cb3ac/src/View/Helper/MailhideHelper.php#L35-L43
train
mirko-pagliai/cakephp-recaptcha-mailhide
src/View/Helper/MailhideHelper.php
MailhideHelper.link
public function link($title, $mail, array $options = []) { //Obfuscates the title, if the title is the email address $title = filter_var($title, FILTER_VALIDATE_EMAIL) ? $this->obfuscate($title) : $title; $mail = Security::encryptMail($mail); $url = Router::url(['_name' => 'mailhide', '?' => compact('mail')], true); $options['escape'] = false; $options['onClick'] = sprintf('window.open(\'%s\',\'%s\',\'resizable,height=547,width=334\'); return false;', $url, $title); $options += ['class' => 'recaptcha-mailhide', 'title' => $title]; return $this->Html->link($title, $url, $options); }
php
public function link($title, $mail, array $options = []) { //Obfuscates the title, if the title is the email address $title = filter_var($title, FILTER_VALIDATE_EMAIL) ? $this->obfuscate($title) : $title; $mail = Security::encryptMail($mail); $url = Router::url(['_name' => 'mailhide', '?' => compact('mail')], true); $options['escape'] = false; $options['onClick'] = sprintf('window.open(\'%s\',\'%s\',\'resizable,height=547,width=334\'); return false;', $url, $title); $options += ['class' => 'recaptcha-mailhide', 'title' => $title]; return $this->Html->link($title, $url, $options); }
[ "public", "function", "link", "(", "$", "title", ",", "$", "mail", ",", "array", "$", "options", "=", "[", "]", ")", "{", "//Obfuscates the title, if the title is the email address", "$", "title", "=", "filter_var", "(", "$", "title", ",", "FILTER_VALIDATE_EMAIL...
Creates a link for the page where you enter the code and from which the clear email address will be displayed @param string $title Link title. If it is the email address, it will be obfuscated @param string $mail Email for which you want to create the link. It will not be shown clearly @param array $options Array of options and HTML attributes @return string An `<a />` element @uses \RecaptchaMailhide\Utility\Security::encryptMail() @uses obfuscate()
[ "Creates", "a", "link", "for", "the", "page", "where", "you", "enter", "the", "code", "and", "from", "which", "the", "clear", "email", "address", "will", "be", "displayed" ]
d3a9acaea5382b20cd36f794d75265337d5cb3ac
https://github.com/mirko-pagliai/cakephp-recaptcha-mailhide/blob/d3a9acaea5382b20cd36f794d75265337d5cb3ac/src/View/Helper/MailhideHelper.php#L57-L70
train
vanilla/garden-db
src/Query.php
Query.beginBracket
private function beginBracket($op) { $this->currentWhere[] = [$op => []]; $this->whereStack[] = &$this->currentWhere; end($this->currentWhere); $this->currentWhere = &$this->currentWhere[key($this->currentWhere)][$op]; return $this; }
php
private function beginBracket($op) { $this->currentWhere[] = [$op => []]; $this->whereStack[] = &$this->currentWhere; end($this->currentWhere); $this->currentWhere = &$this->currentWhere[key($this->currentWhere)][$op]; return $this; }
[ "private", "function", "beginBracket", "(", "$", "op", ")", "{", "$", "this", "->", "currentWhere", "[", "]", "=", "[", "$", "op", "=>", "[", "]", "]", ";", "$", "this", "->", "whereStack", "[", "]", "=", "&", "$", "this", "->", "currentWhere", "...
Begin a bracket group in the WHERE clause. @param string $op One of the **DB::OP_*** constants. @return $this
[ "Begin", "a", "bracket", "group", "in", "the", "WHERE", "clause", "." ]
2634229fb7a161f649ad371e59a973ccbbe72247
https://github.com/vanilla/garden-db/blob/2634229fb7a161f649ad371e59a973ccbbe72247/src/Query.php#L89-L96
train
vanilla/garden-db
src/Query.php
Query.end
public function end() { // First unset the reference so it doesn't overwrite the original where clause. unset($this->currentWhere); // Move the pointer in the where stack back one level. if (empty($this->whereStack)) { trigger_error("Call to Query->end() without a corresponding call to Query->begin*().", E_USER_NOTICE); $this->currentWhere = &$this->where; } else { $key = key(end($this->whereStack)); $this->currentWhere = &$this->whereStack[$key]; unset($this->whereStack[$key]); } return $this; }
php
public function end() { // First unset the reference so it doesn't overwrite the original where clause. unset($this->currentWhere); // Move the pointer in the where stack back one level. if (empty($this->whereStack)) { trigger_error("Call to Query->end() without a corresponding call to Query->begin*().", E_USER_NOTICE); $this->currentWhere = &$this->where; } else { $key = key(end($this->whereStack)); $this->currentWhere = &$this->whereStack[$key]; unset($this->whereStack[$key]); } return $this; }
[ "public", "function", "end", "(", ")", "{", "// First unset the reference so it doesn't overwrite the original where clause.", "unset", "(", "$", "this", "->", "currentWhere", ")", ";", "// Move the pointer in the where stack back one level.", "if", "(", "empty", "(", "$", ...
End a bracket group. @return $this @see Query::beginAnd(), Query::beginOr()
[ "End", "a", "bracket", "group", "." ]
2634229fb7a161f649ad371e59a973ccbbe72247
https://github.com/vanilla/garden-db/blob/2634229fb7a161f649ad371e59a973ccbbe72247/src/Query.php#L104-L119
train
vanilla/garden-db
src/Query.php
Query.addLike
public function addLike($column, $value) { $r = $this->addWhere($column, [Db::OP_LIKE => $value]); return $r; }
php
public function addLike($column, $value) { $r = $this->addWhere($column, [Db::OP_LIKE => $value]); return $r; }
[ "public", "function", "addLike", "(", "$", "column", ",", "$", "value", ")", "{", "$", "r", "=", "$", "this", "->", "addWhere", "(", "$", "column", ",", "[", "Db", "::", "OP_LIKE", "=>", "$", "value", "]", ")", ";", "return", "$", "r", ";", "}"...
Add a like statement to the current where clause. @param string $column The name of the column to compare. @param string $value The like query. @return $this
[ "Add", "a", "like", "statement", "to", "the", "current", "where", "clause", "." ]
2634229fb7a161f649ad371e59a973ccbbe72247
https://github.com/vanilla/garden-db/blob/2634229fb7a161f649ad371e59a973ccbbe72247/src/Query.php#L174-L177
train
vanilla/garden-db
src/Query.php
Query.addIn
public function addIn($column, array $values) { $r = $this->addWhere($column, [Db::OP_IN, $values]); return $r; }
php
public function addIn($column, array $values) { $r = $this->addWhere($column, [Db::OP_IN, $values]); return $r; }
[ "public", "function", "addIn", "(", "$", "column", ",", "array", "$", "values", ")", "{", "$", "r", "=", "$", "this", "->", "addWhere", "(", "$", "column", ",", "[", "Db", "::", "OP_IN", ",", "$", "values", "]", ")", ";", "return", "$", "r", ";...
Add an in statement to the current where clause. @param string $column The name of the column to compare. @param array $values The in list to check against. @return $this
[ "Add", "an", "in", "statement", "to", "the", "current", "where", "clause", "." ]
2634229fb7a161f649ad371e59a973ccbbe72247
https://github.com/vanilla/garden-db/blob/2634229fb7a161f649ad371e59a973ccbbe72247/src/Query.php#L186-L189
train
vanilla/garden-db
src/Query.php
Query.addWheres
public function addWheres(array $where) { foreach ($where as $column => $value) { $this->addWhere($column, $value); } return $this; }
php
public function addWheres(array $where) { foreach ($where as $column => $value) { $this->addWhere($column, $value); } return $this; }
[ "public", "function", "addWheres", "(", "array", "$", "where", ")", "{", "foreach", "(", "$", "where", "as", "$", "column", "=>", "$", "value", ")", "{", "$", "this", "->", "addWhere", "(", "$", "column", ",", "$", "value", ")", ";", "}", "return",...
Add an array of where statements. This method takes an array where the keys represent column names and the values represent filter values. ```php $query->where([ 'parentID' => 123, 'count' => [Db::GT => 0] ]); ``` @param array $where The array of where statements to add to the query. @return $this @see Query::addWhere()
[ "Add", "an", "array", "of", "where", "statements", "." ]
2634229fb7a161f649ad371e59a973ccbbe72247
https://github.com/vanilla/garden-db/blob/2634229fb7a161f649ad371e59a973ccbbe72247/src/Query.php#L207-L212
train
vanilla/garden-db
src/Query.php
Query.toArray
public function toArray() { $r = [ 'from' => $this->from, 'where' => $this->where, 'order' => $this->order, 'limit' => $this->limit, 'offset' => $this->offset ]; return $r; }
php
public function toArray() { $r = [ 'from' => $this->from, 'where' => $this->where, 'order' => $this->order, 'limit' => $this->limit, 'offset' => $this->offset ]; return $r; }
[ "public", "function", "toArray", "(", ")", "{", "$", "r", "=", "[", "'from'", "=>", "$", "this", "->", "from", ",", "'where'", "=>", "$", "this", "->", "where", ",", "'order'", "=>", "$", "this", "->", "order", ",", "'limit'", "=>", "$", "this", ...
Return an array representation of this query. @return array Returns an array with keys representing the query parts.
[ "Return", "an", "array", "representation", "of", "this", "query", "." ]
2634229fb7a161f649ad371e59a973ccbbe72247
https://github.com/vanilla/garden-db/blob/2634229fb7a161f649ad371e59a973ccbbe72247/src/Query.php#L219-L229
train
vanilla/garden-db
src/Query.php
Query.exec
public function exec(Db $db) { $options = [ 'limit' => $this->limit, 'offset' => $this->offset ]; $r = $db->get($this->from, $this->where, $options); return $r; }
php
public function exec(Db $db) { $options = [ 'limit' => $this->limit, 'offset' => $this->offset ]; $r = $db->get($this->from, $this->where, $options); return $r; }
[ "public", "function", "exec", "(", "Db", "$", "db", ")", "{", "$", "options", "=", "[", "'limit'", "=>", "$", "this", "->", "limit", ",", "'offset'", "=>", "$", "this", "->", "offset", "]", ";", "$", "r", "=", "$", "db", "->", "get", "(", "$", ...
Execute this query against a database. @param Db $db The database to query. @return \PDOStatement Returns the query result.
[ "Execute", "this", "query", "against", "a", "database", "." ]
2634229fb7a161f649ad371e59a973ccbbe72247
https://github.com/vanilla/garden-db/blob/2634229fb7a161f649ad371e59a973ccbbe72247/src/Query.php#L237-L245
train
mirko-pagliai/me-cms
src/Model/Table/Traits/IsOwnedByTrait.php
IsOwnedByTrait.isOwnedBy
public function isOwnedBy($recordId, $userId = null) { return (bool)$this->find() ->where(['id' => $recordId, 'user_id' => $userId]) ->first(); }
php
public function isOwnedBy($recordId, $userId = null) { return (bool)$this->find() ->where(['id' => $recordId, 'user_id' => $userId]) ->first(); }
[ "public", "function", "isOwnedBy", "(", "$", "recordId", ",", "$", "userId", "=", "null", ")", "{", "return", "(", "bool", ")", "$", "this", "->", "find", "(", ")", "->", "where", "(", "[", "'id'", "=>", "$", "recordId", ",", "'user_id'", "=>", "$"...
Checks if a record is owned by an user. Example: <code> $posts->isOwnedBy(2, 4); </code> it checks if the posts with ID 2 belongs to the user with ID 4. @param int $recordId Record ID @param int $userId User ID @return bool
[ "Checks", "if", "a", "record", "is", "owned", "by", "an", "user", "." ]
df668ad8e3ee221497c47578d474e487f24ce92a
https://github.com/mirko-pagliai/me-cms/blob/df668ad8e3ee221497c47578d474e487f24ce92a/src/Model/Table/Traits/IsOwnedByTrait.php#L32-L37
train
mirko-pagliai/me-cms
src/View/Helper/MenuHelper.php
MenuHelper.posts
public function posts() { $links[] = [__d('me_cms', 'List posts'), [ 'controller' => 'Posts', 'action' => 'index', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; $links[] = [__d('me_cms', 'Add post'), [ 'controller' => 'Posts', 'action' => 'add', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; //Only admins and managers can access these actions if ($this->Auth->isGroup(['admin', 'manager'])) { $links[] = [__d('me_cms', 'List categories'), [ 'controller' => 'PostsCategories', 'action' => 'index', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; $links[] = [__d('me_cms', 'Add category'), [ 'controller' => 'PostsCategories', 'action' => 'add', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; } $links[] = [__d('me_cms', 'List tags'), [ 'controller' => 'PostsTags', 'action' => 'index', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; return [$links, I18N_POSTS, ['icon' => 'far file-alt']]; }
php
public function posts() { $links[] = [__d('me_cms', 'List posts'), [ 'controller' => 'Posts', 'action' => 'index', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; $links[] = [__d('me_cms', 'Add post'), [ 'controller' => 'Posts', 'action' => 'add', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; //Only admins and managers can access these actions if ($this->Auth->isGroup(['admin', 'manager'])) { $links[] = [__d('me_cms', 'List categories'), [ 'controller' => 'PostsCategories', 'action' => 'index', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; $links[] = [__d('me_cms', 'Add category'), [ 'controller' => 'PostsCategories', 'action' => 'add', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; } $links[] = [__d('me_cms', 'List tags'), [ 'controller' => 'PostsTags', 'action' => 'index', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; return [$links, I18N_POSTS, ['icon' => 'far file-alt']]; }
[ "public", "function", "posts", "(", ")", "{", "$", "links", "[", "]", "=", "[", "__d", "(", "'me_cms'", ",", "'List posts'", ")", ",", "[", "'controller'", "=>", "'Posts'", ",", "'action'", "=>", "'index'", ",", "'plugin'", "=>", "'MeCms'", ",", "'pref...
Internal function to generate the menu for "posts" actions @return mixed Array with links, title and title options
[ "Internal", "function", "to", "generate", "the", "menu", "for", "posts", "actions" ]
df668ad8e3ee221497c47578d474e487f24ce92a
https://github.com/mirko-pagliai/me-cms/blob/df668ad8e3ee221497c47578d474e487f24ce92a/src/View/Helper/MenuHelper.php#L38-L77
train
mirko-pagliai/me-cms
src/View/Helper/MenuHelper.php
MenuHelper.pages
public function pages() { $links[] = [__d('me_cms', 'List pages'), [ 'controller' => 'Pages', 'action' => 'index', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; //Only admins and managers can access these actions if ($this->Auth->isGroup(['admin', 'manager'])) { $links[] = [__d('me_cms', 'Add page'), [ 'controller' => 'Pages', 'action' => 'add', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; $links[] = [__d('me_cms', 'List categories'), [ 'controller' => 'PagesCategories', 'action' => 'index', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; $links[] = [__d('me_cms', 'Add category'), [ 'controller' => 'PagesCategories', 'action' => 'add', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; } $links[] = [__d('me_cms', 'List static pages'), [ 'controller' => 'Pages', 'action' => 'indexStatics', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; return [$links, I18N_PAGES, ['icon' => 'far copy']]; }
php
public function pages() { $links[] = [__d('me_cms', 'List pages'), [ 'controller' => 'Pages', 'action' => 'index', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; //Only admins and managers can access these actions if ($this->Auth->isGroup(['admin', 'manager'])) { $links[] = [__d('me_cms', 'Add page'), [ 'controller' => 'Pages', 'action' => 'add', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; $links[] = [__d('me_cms', 'List categories'), [ 'controller' => 'PagesCategories', 'action' => 'index', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; $links[] = [__d('me_cms', 'Add category'), [ 'controller' => 'PagesCategories', 'action' => 'add', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; } $links[] = [__d('me_cms', 'List static pages'), [ 'controller' => 'Pages', 'action' => 'indexStatics', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; return [$links, I18N_PAGES, ['icon' => 'far copy']]; }
[ "public", "function", "pages", "(", ")", "{", "$", "links", "[", "]", "=", "[", "__d", "(", "'me_cms'", ",", "'List pages'", ")", ",", "[", "'controller'", "=>", "'Pages'", ",", "'action'", "=>", "'index'", ",", "'plugin'", "=>", "'MeCms'", ",", "'pref...
Internal function to generate the menu for "pages" actions @return mixed Array with links, title and title options
[ "Internal", "function", "to", "generate", "the", "menu", "for", "pages", "actions" ]
df668ad8e3ee221497c47578d474e487f24ce92a
https://github.com/mirko-pagliai/me-cms/blob/df668ad8e3ee221497c47578d474e487f24ce92a/src/View/Helper/MenuHelper.php#L83-L122
train
mirko-pagliai/me-cms
src/View/Helper/MenuHelper.php
MenuHelper.photos
public function photos() { $links[] = [__d('me_cms', 'List photos'), [ 'controller' => 'Photos', 'action' => 'index', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; $links[] = [__d('me_cms', 'Upload photos'), [ 'controller' => 'Photos', 'action' => 'upload', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; $links[] = [__d('me_cms', 'List albums'), [ 'controller' => 'PhotosAlbums', 'action' => 'index', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; $links[] = [__d('me_cms', 'Add album'), [ 'controller' => 'PhotosAlbums', 'action' => 'add', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; return [$links, I18N_PHOTOS, ['icon' => 'camera-retro']]; }
php
public function photos() { $links[] = [__d('me_cms', 'List photos'), [ 'controller' => 'Photos', 'action' => 'index', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; $links[] = [__d('me_cms', 'Upload photos'), [ 'controller' => 'Photos', 'action' => 'upload', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; $links[] = [__d('me_cms', 'List albums'), [ 'controller' => 'PhotosAlbums', 'action' => 'index', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; $links[] = [__d('me_cms', 'Add album'), [ 'controller' => 'PhotosAlbums', 'action' => 'add', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; return [$links, I18N_PHOTOS, ['icon' => 'camera-retro']]; }
[ "public", "function", "photos", "(", ")", "{", "$", "links", "[", "]", "=", "[", "__d", "(", "'me_cms'", ",", "'List photos'", ")", ",", "[", "'controller'", "=>", "'Photos'", ",", "'action'", "=>", "'index'", ",", "'plugin'", "=>", "'MeCms'", ",", "'p...
Internal function to generate the menu for "photos" actions @return mixed Array with links, title and title options
[ "Internal", "function", "to", "generate", "the", "menu", "for", "photos", "actions" ]
df668ad8e3ee221497c47578d474e487f24ce92a
https://github.com/mirko-pagliai/me-cms/blob/df668ad8e3ee221497c47578d474e487f24ce92a/src/View/Helper/MenuHelper.php#L128-L156
train
mirko-pagliai/me-cms
src/View/Helper/MenuHelper.php
MenuHelper.banners
public function banners() { //Only admins and managers can access these controllers if (!$this->Auth->isGroup(['admin', 'manager'])) { return; } $links[] = [__d('me_cms', 'List banners'), [ 'controller' => 'Banners', 'action' => 'index', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; $links[] = [__d('me_cms', 'Upload banners'), [ 'controller' => 'Banners', 'action' => 'upload', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; //Only admin can access this controller if ($this->Auth->isGroup('admin')) { $links[] = [__d('me_cms', 'List positions'), [ 'controller' => 'BannersPositions', 'action' => 'index', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; $links[] = [__d('me_cms', 'Add position'), [ 'controller' => 'BannersPositions', 'action' => 'add', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; } return [$links, __d('me_cms', 'Banners'), ['icon' => 'shopping-cart']]; }
php
public function banners() { //Only admins and managers can access these controllers if (!$this->Auth->isGroup(['admin', 'manager'])) { return; } $links[] = [__d('me_cms', 'List banners'), [ 'controller' => 'Banners', 'action' => 'index', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; $links[] = [__d('me_cms', 'Upload banners'), [ 'controller' => 'Banners', 'action' => 'upload', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; //Only admin can access this controller if ($this->Auth->isGroup('admin')) { $links[] = [__d('me_cms', 'List positions'), [ 'controller' => 'BannersPositions', 'action' => 'index', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; $links[] = [__d('me_cms', 'Add position'), [ 'controller' => 'BannersPositions', 'action' => 'add', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; } return [$links, __d('me_cms', 'Banners'), ['icon' => 'shopping-cart']]; }
[ "public", "function", "banners", "(", ")", "{", "//Only admins and managers can access these controllers", "if", "(", "!", "$", "this", "->", "Auth", "->", "isGroup", "(", "[", "'admin'", ",", "'manager'", "]", ")", ")", "{", "return", ";", "}", "$", "links"...
Internal function to generate the menu for "banners" actions @return mixed Array with links, title and title options
[ "Internal", "function", "to", "generate", "the", "menu", "for", "banners", "actions" ]
df668ad8e3ee221497c47578d474e487f24ce92a
https://github.com/mirko-pagliai/me-cms/blob/df668ad8e3ee221497c47578d474e487f24ce92a/src/View/Helper/MenuHelper.php#L162-L199
train
mirko-pagliai/me-cms
src/View/Helper/MenuHelper.php
MenuHelper.users
public function users() { //Only admins and managers can access this controller if (!$this->Auth->isGroup(['admin', 'manager'])) { return; } $links[] = [__d('me_cms', 'List users'), [ 'controller' => 'Users', 'action' => 'index', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; $links[] = [__d('me_cms', 'Add user'), [ 'controller' => 'Users', 'action' => 'add', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; //Only admins can access these actions if ($this->Auth->isGroup('admin')) { $links[] = [__d('me_cms', 'List groups'), [ 'controller' => 'UsersGroups', 'action' => 'index', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; $links[] = [__d('me_cms', 'Add group'), [ 'controller' => 'UsersGroups', 'action' => 'add', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; } return [$links, I18N_USERS, ['icon' => 'users']]; }
php
public function users() { //Only admins and managers can access this controller if (!$this->Auth->isGroup(['admin', 'manager'])) { return; } $links[] = [__d('me_cms', 'List users'), [ 'controller' => 'Users', 'action' => 'index', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; $links[] = [__d('me_cms', 'Add user'), [ 'controller' => 'Users', 'action' => 'add', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; //Only admins can access these actions if ($this->Auth->isGroup('admin')) { $links[] = [__d('me_cms', 'List groups'), [ 'controller' => 'UsersGroups', 'action' => 'index', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; $links[] = [__d('me_cms', 'Add group'), [ 'controller' => 'UsersGroups', 'action' => 'add', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; } return [$links, I18N_USERS, ['icon' => 'users']]; }
[ "public", "function", "users", "(", ")", "{", "//Only admins and managers can access this controller", "if", "(", "!", "$", "this", "->", "Auth", "->", "isGroup", "(", "[", "'admin'", ",", "'manager'", "]", ")", ")", "{", "return", ";", "}", "$", "links", ...
Internal function to generate the menu for "users" actions @return mixed Array with links, title and title options
[ "Internal", "function", "to", "generate", "the", "menu", "for", "users", "actions" ]
df668ad8e3ee221497c47578d474e487f24ce92a
https://github.com/mirko-pagliai/me-cms/blob/df668ad8e3ee221497c47578d474e487f24ce92a/src/View/Helper/MenuHelper.php#L205-L242
train
mirko-pagliai/me-cms
src/View/Helper/MenuHelper.php
MenuHelper.backups
public function backups() { //Only admins can access this controller if (!$this->Auth->isGroup('admin')) { return; } $links[] = [__d('me_cms', 'List backups'), [ 'controller' => 'Backups', 'action' => 'index', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; $links[] = [__d('me_cms', 'Add backup'), [ 'controller' => 'Backups', 'action' => 'add', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; return [$links, __d('me_cms', 'Backups'), ['icon' => 'database']]; }
php
public function backups() { //Only admins can access this controller if (!$this->Auth->isGroup('admin')) { return; } $links[] = [__d('me_cms', 'List backups'), [ 'controller' => 'Backups', 'action' => 'index', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; $links[] = [__d('me_cms', 'Add backup'), [ 'controller' => 'Backups', 'action' => 'add', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; return [$links, __d('me_cms', 'Backups'), ['icon' => 'database']]; }
[ "public", "function", "backups", "(", ")", "{", "//Only admins can access this controller", "if", "(", "!", "$", "this", "->", "Auth", "->", "isGroup", "(", "'admin'", ")", ")", "{", "return", ";", "}", "$", "links", "[", "]", "=", "[", "__d", "(", "'m...
Internal function to generate the menu for "backups" actions @return mixed Array with links, title and title options
[ "Internal", "function", "to", "generate", "the", "menu", "for", "backups", "actions" ]
df668ad8e3ee221497c47578d474e487f24ce92a
https://github.com/mirko-pagliai/me-cms/blob/df668ad8e3ee221497c47578d474e487f24ce92a/src/View/Helper/MenuHelper.php#L248-L269
train
mirko-pagliai/me-cms
src/View/Helper/MenuHelper.php
MenuHelper.systems
public function systems() { //Only admins and managers can access this controller if (!$this->Auth->isGroup(['admin', 'manager'])) { return; } $links[] = [__d('me_cms', 'Temporary files'), [ 'controller' => 'Systems', 'action' => 'tmpViewer', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; //Only admins can manage logs if ($this->Auth->isGroup('admin')) { $links[] = [__d('me_cms', 'Log management'), [ 'controller' => 'Logs', 'action' => 'index', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; } $links[] = [__d('me_cms', 'System checkup'), [ 'controller' => 'Systems', 'action' => 'checkup', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; $links[] = [__d('me_cms', 'Media browser'), [ 'controller' => 'Systems', 'action' => 'browser', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; $links[] = [__d('me_cms', 'Changelogs'), [ 'controller' => 'Systems', 'action' => 'changelogs', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; return [$links, __d('me_cms', 'System'), ['icon' => 'wrench']]; }
php
public function systems() { //Only admins and managers can access this controller if (!$this->Auth->isGroup(['admin', 'manager'])) { return; } $links[] = [__d('me_cms', 'Temporary files'), [ 'controller' => 'Systems', 'action' => 'tmpViewer', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; //Only admins can manage logs if ($this->Auth->isGroup('admin')) { $links[] = [__d('me_cms', 'Log management'), [ 'controller' => 'Logs', 'action' => 'index', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; } $links[] = [__d('me_cms', 'System checkup'), [ 'controller' => 'Systems', 'action' => 'checkup', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; $links[] = [__d('me_cms', 'Media browser'), [ 'controller' => 'Systems', 'action' => 'browser', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; $links[] = [__d('me_cms', 'Changelogs'), [ 'controller' => 'Systems', 'action' => 'changelogs', 'plugin' => 'MeCms', 'prefix' => ADMIN_PREFIX, ]]; return [$links, __d('me_cms', 'System'), ['icon' => 'wrench']]; }
[ "public", "function", "systems", "(", ")", "{", "//Only admins and managers can access this controller", "if", "(", "!", "$", "this", "->", "Auth", "->", "isGroup", "(", "[", "'admin'", ",", "'manager'", "]", ")", ")", "{", "return", ";", "}", "$", "links", ...
Internal function to generate the menu for "systems" actions @return mixed Array with links, title and title options
[ "Internal", "function", "to", "generate", "the", "menu", "for", "systems", "actions" ]
df668ad8e3ee221497c47578d474e487f24ce92a
https://github.com/mirko-pagliai/me-cms/blob/df668ad8e3ee221497c47578d474e487f24ce92a/src/View/Helper/MenuHelper.php#L275-L319
train
TuumPHP/Respond
src/Controller/ControllerTrait.php
ControllerTrait.dispatch
protected function dispatch($request, $response) { $this->setRequest($request); $this->setResponse($response); if (!$this->responder) { $this->responder = Respond::getResponder(); } return $this->_execInternalMethods(); }
php
protected function dispatch($request, $response) { $this->setRequest($request); $this->setResponse($response); if (!$this->responder) { $this->responder = Respond::getResponder(); } return $this->_execInternalMethods(); }
[ "protected", "function", "dispatch", "(", "$", "request", ",", "$", "response", ")", "{", "$", "this", "->", "setRequest", "(", "$", "request", ")", ";", "$", "this", "->", "setResponse", "(", "$", "response", ")", ";", "if", "(", "!", "$", "this", ...
call this dispatch method to respond. @param ServerRequestInterface $request @param ResponseInterface $response @return ResponseInterface|null
[ "call", "this", "dispatch", "method", "to", "respond", "." ]
5861ec0bffc97c500d88bf307a53277f1c2fe12f
https://github.com/TuumPHP/Respond/blob/5861ec0bffc97c500d88bf307a53277f1c2fe12f/src/Controller/ControllerTrait.php#L17-L25
train
fxpio/fxp-swiftmailer-doctrine
Spool/DoctrineSpool.php
DoctrineSpool.sendEmails
protected function sendEmails(Swift_Transport $transport, &$failedRecipients, array $emails) { $count = 0; $time = time(); $emails = $this->prepareEmails($emails); $skip = false; foreach ($emails as $email) { if ($skip) { $email->setStatus(SpoolEmailStatus::STATUS_FAILED); $email->setStatusMessage('The time limit of execution is exceeded'); continue; } $count += $this->sendEmail($transport, $email, $failedRecipients); $this->flushEmail($email); if ($this->getTimeLimit() && (time() - $time) >= $this->getTimeLimit()) { $skip = true; } } return $count; }
php
protected function sendEmails(Swift_Transport $transport, &$failedRecipients, array $emails) { $count = 0; $time = time(); $emails = $this->prepareEmails($emails); $skip = false; foreach ($emails as $email) { if ($skip) { $email->setStatus(SpoolEmailStatus::STATUS_FAILED); $email->setStatusMessage('The time limit of execution is exceeded'); continue; } $count += $this->sendEmail($transport, $email, $failedRecipients); $this->flushEmail($email); if ($this->getTimeLimit() && (time() - $time) >= $this->getTimeLimit()) { $skip = true; } } return $count; }
[ "protected", "function", "sendEmails", "(", "Swift_Transport", "$", "transport", ",", "&", "$", "failedRecipients", ",", "array", "$", "emails", ")", "{", "$", "count", "=", "0", ";", "$", "time", "=", "time", "(", ")", ";", "$", "emails", "=", "$", ...
Send the emails message. @param \Swift_Transport $transport The swift transport @param null|string[] $failedRecipients The failed recipients @param SpoolEmailInterface[] $emails The spool emails @return int The count of sent emails
[ "Send", "the", "emails", "message", "." ]
707f259663ea2acce2e287720228c41e4068ce53
https://github.com/fxpio/fxp-swiftmailer-doctrine/blob/707f259663ea2acce2e287720228c41e4068ce53/Spool/DoctrineSpool.php#L151-L175
train
fxpio/fxp-swiftmailer-doctrine
Spool/DoctrineSpool.php
DoctrineSpool.prepareEmails
protected function prepareEmails(array $emails) { foreach ($emails as $email) { $email->setStatus(SpoolEmailStatus::STATUS_SENDING); $email->setSentAt(null); $this->om->persist($email); } $this->om->flush(); reset($emails); return $emails; }
php
protected function prepareEmails(array $emails) { foreach ($emails as $email) { $email->setStatus(SpoolEmailStatus::STATUS_SENDING); $email->setSentAt(null); $this->om->persist($email); } $this->om->flush(); reset($emails); return $emails; }
[ "protected", "function", "prepareEmails", "(", "array", "$", "emails", ")", "{", "foreach", "(", "$", "emails", "as", "$", "email", ")", "{", "$", "email", "->", "setStatus", "(", "SpoolEmailStatus", "::", "STATUS_SENDING", ")", ";", "$", "email", "->", ...
Prepare the spool emails. @param SpoolEmailInterface[] $emails The spool emails @return SpoolEmailInterface[]
[ "Prepare", "the", "spool", "emails", "." ]
707f259663ea2acce2e287720228c41e4068ce53
https://github.com/fxpio/fxp-swiftmailer-doctrine/blob/707f259663ea2acce2e287720228c41e4068ce53/Spool/DoctrineSpool.php#L184-L196
train
fxpio/fxp-swiftmailer-doctrine
Spool/DoctrineSpool.php
DoctrineSpool.sendEmail
protected function sendEmail(Swift_Transport $transport, SpoolEmailInterface $email, &$failedRecipients) { $count = 0; try { if ($transport->send($email->getMessage(), $failedRecipients)) { $email->setStatus(SpoolEmailStatus::STATUS_SUCCESS); ++$count; } else { $email->setStatus(SpoolEmailStatus::STATUS_FAILED); } } catch (\Swift_TransportException $e) { $email->setStatus(SpoolEmailStatus::STATUS_FAILED); $email->setStatusMessage($e->getMessage()); } return $count; }
php
protected function sendEmail(Swift_Transport $transport, SpoolEmailInterface $email, &$failedRecipients) { $count = 0; try { if ($transport->send($email->getMessage(), $failedRecipients)) { $email->setStatus(SpoolEmailStatus::STATUS_SUCCESS); ++$count; } else { $email->setStatus(SpoolEmailStatus::STATUS_FAILED); } } catch (\Swift_TransportException $e) { $email->setStatus(SpoolEmailStatus::STATUS_FAILED); $email->setStatusMessage($e->getMessage()); } return $count; }
[ "protected", "function", "sendEmail", "(", "Swift_Transport", "$", "transport", ",", "SpoolEmailInterface", "$", "email", ",", "&", "$", "failedRecipients", ")", "{", "$", "count", "=", "0", ";", "try", "{", "if", "(", "$", "transport", "->", "send", "(", ...
Send the spool email. @param Swift_Transport $transport The swiftmailer transport @param SpoolEmailInterface $email The spool email @param null|string[] $failedRecipients The failed recipients @return int The count
[ "Send", "the", "spool", "email", "." ]
707f259663ea2acce2e287720228c41e4068ce53
https://github.com/fxpio/fxp-swiftmailer-doctrine/blob/707f259663ea2acce2e287720228c41e4068ce53/Spool/DoctrineSpool.php#L207-L224
train
fxpio/fxp-swiftmailer-doctrine
Spool/DoctrineSpool.php
DoctrineSpool.flushEmail
protected function flushEmail(SpoolEmailInterface $email): void { $email->setSentAt(new \DateTime()); $this->om->persist($email); $this->om->flush(); if (SpoolEmailStatus::STATUS_SUCCESS === $email->getStatus()) { $this->om->remove($email); $this->om->flush(); } $this->om->detach($email); }
php
protected function flushEmail(SpoolEmailInterface $email): void { $email->setSentAt(new \DateTime()); $this->om->persist($email); $this->om->flush(); if (SpoolEmailStatus::STATUS_SUCCESS === $email->getStatus()) { $this->om->remove($email); $this->om->flush(); } $this->om->detach($email); }
[ "protected", "function", "flushEmail", "(", "SpoolEmailInterface", "$", "email", ")", ":", "void", "{", "$", "email", "->", "setSentAt", "(", "new", "\\", "DateTime", "(", ")", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "email", ")",...
Update and flush the spool email. @param SpoolEmailInterface $email The spool email
[ "Update", "and", "flush", "the", "spool", "email", "." ]
707f259663ea2acce2e287720228c41e4068ce53
https://github.com/fxpio/fxp-swiftmailer-doctrine/blob/707f259663ea2acce2e287720228c41e4068ce53/Spool/DoctrineSpool.php#L231-L243
train
mirko-pagliai/me-cms
src/Model/Table/AppTable.php
AppTable.beforeSave
public function beforeSave(Event $event, EntityInterface $entity, ArrayObject $options) { if (empty($entity->created)) { $entity->created = new Time; } elseif (!empty($entity->created) && !$entity->created instanceof Time) { $entity->created = new Time($entity->created); } }
php
public function beforeSave(Event $event, EntityInterface $entity, ArrayObject $options) { if (empty($entity->created)) { $entity->created = new Time; } elseif (!empty($entity->created) && !$entity->created instanceof Time) { $entity->created = new Time($entity->created); } }
[ "public", "function", "beforeSave", "(", "Event", "$", "event", ",", "EntityInterface", "$", "entity", ",", "ArrayObject", "$", "options", ")", "{", "if", "(", "empty", "(", "$", "entity", "->", "created", ")", ")", "{", "$", "entity", "->", "created", ...
Called before each entity is saved. Stopping this event will abort the save operation. When the event is stopped the result of the event will be returned @param \Cake\Event\Event $event Event object @param \Cake\Datasource\EntityInterface $entity EntityInterface object @param \ArrayObject $options Options @return void @since 2.16.1
[ "Called", "before", "each", "entity", "is", "saved", ".", "Stopping", "this", "event", "will", "abort", "the", "save", "operation", ".", "When", "the", "event", "is", "stopped", "the", "result", "of", "the", "event", "will", "be", "returned" ]
df668ad8e3ee221497c47578d474e487f24ce92a
https://github.com/mirko-pagliai/me-cms/blob/df668ad8e3ee221497c47578d474e487f24ce92a/src/Model/Table/AppTable.php#L75-L82
train
mirko-pagliai/me-cms
src/Model/Table/AppTable.php
AppTable.findRandom
public function findRandom(Query $query, array $options) { $query->order('rand()'); if (!$query->clause('limit')) { $query->limit(1); } return $query; }
php
public function findRandom(Query $query, array $options) { $query->order('rand()'); if (!$query->clause('limit')) { $query->limit(1); } return $query; }
[ "public", "function", "findRandom", "(", "Query", "$", "query", ",", "array", "$", "options", ")", "{", "$", "query", "->", "order", "(", "'rand()'", ")", ";", "if", "(", "!", "$", "query", "->", "clause", "(", "'limit'", ")", ")", "{", "$", "query...
"random" find method @param Query $query Query object @param array $options Options @return Query Query object
[ "random", "find", "method" ]
df668ad8e3ee221497c47578d474e487f24ce92a
https://github.com/mirko-pagliai/me-cms/blob/df668ad8e3ee221497c47578d474e487f24ce92a/src/Model/Table/AppTable.php#L116-L125
train
mirko-pagliai/me-cms
src/Model/Table/AppTable.php
AppTable.getCacheName
public function getCacheName($associations = false) { $values = $this->cache ?: null; if ($associations) { $values = [$values]; foreach ($this->associations()->getIterator() as $association) { if (method_exists($association->getTarget(), 'getCacheName') && $association->getTarget()->getCacheName()) { $values[] = $association->getTarget()->getCacheName(); } } $values = array_values(array_unique(array_filter($values))); } return $values; }
php
public function getCacheName($associations = false) { $values = $this->cache ?: null; if ($associations) { $values = [$values]; foreach ($this->associations()->getIterator() as $association) { if (method_exists($association->getTarget(), 'getCacheName') && $association->getTarget()->getCacheName()) { $values[] = $association->getTarget()->getCacheName(); } } $values = array_values(array_unique(array_filter($values))); } return $values; }
[ "public", "function", "getCacheName", "(", "$", "associations", "=", "false", ")", "{", "$", "values", "=", "$", "this", "->", "cache", "?", ":", "null", ";", "if", "(", "$", "associations", ")", "{", "$", "values", "=", "[", "$", "values", "]", ";...
Gets the cache configuration name used by this table @param bool $associations If `true`, it returns an array that contains also the names of the associated tables @return string|array|null @since 2.26.0 @uses $cache
[ "Gets", "the", "cache", "configuration", "name", "used", "by", "this", "table" ]
df668ad8e3ee221497c47578d474e487f24ce92a
https://github.com/mirko-pagliai/me-cms/blob/df668ad8e3ee221497c47578d474e487f24ce92a/src/Model/Table/AppTable.php#L135-L151
train
mirko-pagliai/me-cms
src/Model/Table/AppTable.php
AppTable.getList
public function getList() { return $this->find('list') ->order([$this->getDisplayField() => 'ASC']) ->cache(sprintf('%s_list', $this->getTable()), $this->getCacheName()); }
php
public function getList() { return $this->find('list') ->order([$this->getDisplayField() => 'ASC']) ->cache(sprintf('%s_list', $this->getTable()), $this->getCacheName()); }
[ "public", "function", "getList", "(", ")", "{", "return", "$", "this", "->", "find", "(", "'list'", ")", "->", "order", "(", "[", "$", "this", "->", "getDisplayField", "(", ")", "=>", "'ASC'", "]", ")", "->", "cache", "(", "sprintf", "(", "'%s_list'"...
Gets records as list @return Query $query Query object @uses getCacheName()
[ "Gets", "records", "as", "list" ]
df668ad8e3ee221497c47578d474e487f24ce92a
https://github.com/mirko-pagliai/me-cms/blob/df668ad8e3ee221497c47578d474e487f24ce92a/src/Model/Table/AppTable.php#L158-L163
train
vanilla/garden-db
src/Utils/DatasetTrait.php
DatasetTrait.setPage
public function setPage(int $page) { if ($page < 0) { throw new \InvalidArgumentException("Invalid page '$page.'", 500); } $this->setOffset(($page - 1) * $this->getLimit()); return $this; }
php
public function setPage(int $page) { if ($page < 0) { throw new \InvalidArgumentException("Invalid page '$page.'", 500); } $this->setOffset(($page - 1) * $this->getLimit()); return $this; }
[ "public", "function", "setPage", "(", "int", "$", "page", ")", "{", "if", "(", "$", "page", "<", "0", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid page '$page.'\"", ",", "500", ")", ";", "}", "$", "this", "->", "setOffset",...
Set the current page. @param int $page A valid page number. @return $this
[ "Set", "the", "current", "page", "." ]
2634229fb7a161f649ad371e59a973ccbbe72247
https://github.com/vanilla/garden-db/blob/2634229fb7a161f649ad371e59a973ccbbe72247/src/Utils/DatasetTrait.php#L55-L62
train
vanilla/garden-db
src/Utils/DatasetTrait.php
DatasetTrait.setOffset
public function setOffset($offset) { if (!is_numeric($offset) || $offset < 0) { throw new \InvalidArgumentException("Invalid offset '$offset.'", 500); } $this->offset = (int)$offset; return $this; }
php
public function setOffset($offset) { if (!is_numeric($offset) || $offset < 0) { throw new \InvalidArgumentException("Invalid offset '$offset.'", 500); } $this->offset = (int)$offset; return $this; }
[ "public", "function", "setOffset", "(", "$", "offset", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "offset", ")", "||", "$", "offset", "<", "0", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid offset '$offset.'\"", ",", "5...
Set the offset. @param int $offset @return $this
[ "Set", "the", "offset", "." ]
2634229fb7a161f649ad371e59a973ccbbe72247
https://github.com/vanilla/garden-db/blob/2634229fb7a161f649ad371e59a973ccbbe72247/src/Utils/DatasetTrait.php#L214-L221
train
nails/module-console
src/Command/BaseMaker.php
BaseMaker.getResource
protected function getResource(string $sFile, array $aFields): string { if (empty(static::RESOURCE_PATH)) { throw new NailsException('RESOURCE_PATH is not defined'); } $sResource = require static::RESOURCE_PATH . $sFile; foreach ($aFields as $sField => $sValue) { $sKey = '{{' . strtoupper($sField) . '}}'; $sResource = str_replace($sKey, $sValue, $sResource); } return $sResource; }
php
protected function getResource(string $sFile, array $aFields): string { if (empty(static::RESOURCE_PATH)) { throw new NailsException('RESOURCE_PATH is not defined'); } $sResource = require static::RESOURCE_PATH . $sFile; foreach ($aFields as $sField => $sValue) { $sKey = '{{' . strtoupper($sField) . '}}'; $sResource = str_replace($sKey, $sValue, $sResource); } return $sResource; }
[ "protected", "function", "getResource", "(", "string", "$", "sFile", ",", "array", "$", "aFields", ")", ":", "string", "{", "if", "(", "empty", "(", "static", "::", "RESOURCE_PATH", ")", ")", "{", "throw", "new", "NailsException", "(", "'RESOURCE_PATH is not...
Get a resource and substitute fields into it @param string $sFile The file to fetch @param array $aFields The template fields @return string @throws NailsException
[ "Get", "a", "resource", "and", "substitute", "fields", "into", "it" ]
bef013213c914af33172293a386e2738ceedc12d
https://github.com/nails/module-console/blob/bef013213c914af33172293a386e2738ceedc12d/src/Command/BaseMaker.php#L154-L167
train
nails/module-console
src/Command/BaseMaker.php
BaseMaker.createPath
protected function createPath(string $sPath): BaseMaker { if (!is_dir($sPath)) { if (!@mkdir($sPath, self::FILE_PERMISSION, true)) { throw new DoesNotExistException('Path "' . $sPath . '" does not exist and could not be created'); } } if (!is_writable($sPath)) { throw new IsNotWritableException('Path "' . $sPath . '" exists, but is not writable'); } return $this; }
php
protected function createPath(string $sPath): BaseMaker { if (!is_dir($sPath)) { if (!@mkdir($sPath, self::FILE_PERMISSION, true)) { throw new DoesNotExistException('Path "' . $sPath . '" does not exist and could not be created'); } } if (!is_writable($sPath)) { throw new IsNotWritableException('Path "' . $sPath . '" exists, but is not writable'); } return $this; }
[ "protected", "function", "createPath", "(", "string", "$", "sPath", ")", ":", "BaseMaker", "{", "if", "(", "!", "is_dir", "(", "$", "sPath", ")", ")", "{", "if", "(", "!", "@", "mkdir", "(", "$", "sPath", ",", "self", "::", "FILE_PERMISSION", ",", ...
Creates a new path @param string $sPath The path to create @return $this @throws DoesNotExistException @throws IsNotWritableException
[ "Creates", "a", "new", "path" ]
bef013213c914af33172293a386e2738ceedc12d
https://github.com/nails/module-console/blob/bef013213c914af33172293a386e2738ceedc12d/src/Command/BaseMaker.php#L208-L221
train
nails/module-console
src/Command/BaseMaker.php
BaseMaker.getArguments
protected function getArguments(): array { Factory::helper('string'); $aArguments = []; if (!empty($this->aArguments)) { foreach ($this->aArguments as $aArgument) { $aArguments[] = (object) [ 'name' => getFromArray('name', $aArgument), 'value' => $this->oInput->getArgument(getFromArray('name', $aArgument)), 'required' => getFromArray('required', $aArgument), ]; } } else { $aArgumentsRaw = array_slice($this->oInput->getArguments(), 1); foreach ($aArgumentsRaw as $sField => $sValue) { $sField = strtoupper(camelcase_to_underscore($sField)); $aArguments[] = (object) [ 'name' => $sField, 'value' => $sValue, 'required' => true, ]; } } unset($sField); unset($sValue); foreach ($aArguments as &$oArgument) { if (empty($oArgument->value)) { $sLabel = str_replace('_', ' ', $oArgument->name); $sLabel = ucwords(strtolower($sLabel)); $sError = ''; do { $oArgument->value = $this->ask($sError . $sLabel . ':', ''); $sError = '<error>Please specify</error> '; if ($oArgument->required && empty($oArgument->value)) { $bAskAgain = true; } else { $bAskAgain = false; } } while ($bAskAgain); } } unset($oArgument); // Finally set as key values $aOut = []; foreach ($aArguments as $oArgument) { $aOut[strtoupper($oArgument->name)] = $oArgument->value; } return $aOut; }
php
protected function getArguments(): array { Factory::helper('string'); $aArguments = []; if (!empty($this->aArguments)) { foreach ($this->aArguments as $aArgument) { $aArguments[] = (object) [ 'name' => getFromArray('name', $aArgument), 'value' => $this->oInput->getArgument(getFromArray('name', $aArgument)), 'required' => getFromArray('required', $aArgument), ]; } } else { $aArgumentsRaw = array_slice($this->oInput->getArguments(), 1); foreach ($aArgumentsRaw as $sField => $sValue) { $sField = strtoupper(camelcase_to_underscore($sField)); $aArguments[] = (object) [ 'name' => $sField, 'value' => $sValue, 'required' => true, ]; } } unset($sField); unset($sValue); foreach ($aArguments as &$oArgument) { if (empty($oArgument->value)) { $sLabel = str_replace('_', ' ', $oArgument->name); $sLabel = ucwords(strtolower($sLabel)); $sError = ''; do { $oArgument->value = $this->ask($sError . $sLabel . ':', ''); $sError = '<error>Please specify</error> '; if ($oArgument->required && empty($oArgument->value)) { $bAskAgain = true; } else { $bAskAgain = false; } } while ($bAskAgain); } } unset($oArgument); // Finally set as key values $aOut = []; foreach ($aArguments as $oArgument) { $aOut[strtoupper($oArgument->name)] = $oArgument->value; } return $aOut; }
[ "protected", "function", "getArguments", "(", ")", ":", "array", "{", "Factory", "::", "helper", "(", "'string'", ")", ";", "$", "aArguments", "=", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "aArguments", ")", ")", "{", "foreach"...
Parses the arguments into an array ready for templates @return array
[ "Parses", "the", "arguments", "into", "an", "array", "ready", "for", "templates" ]
bef013213c914af33172293a386e2738ceedc12d
https://github.com/nails/module-console/blob/bef013213c914af33172293a386e2738ceedc12d/src/Command/BaseMaker.php#L230-L283
train
nails/module-console
src/Command/BaseMaker.php
BaseMaker.validateServiceFile
protected function validateServiceFile(string $sToken = null): BaseMaker { if (empty($sToken) && empty(static::SERVICE_TOKEN)) { throw new ConsoleException( 'SERVICE_TOKEN is not set' ); } elseif (empty($sToken)) { $sToken = static::SERVICE_TOKEN; } // Detect the services file if (!file_exists(static::SERVICE_PATH)) { throw new ConsoleException( 'Could not detect the app\'s services.php file: ' . static::SERVICE_PATH ); } // Look for the generator token $this->fServicesHandle = fopen(static::SERVICE_PATH, 'r+');; $bFound = false; if ($this->fServicesHandle) { $iLocation = 0; while (($sLine = fgets($this->fServicesHandle)) !== false) { if (preg_match('#^(\s*)// GENERATOR\[' . $sToken . '\]#', $sLine, $aMatches)) { $bFound = true; $this->iServicesIndent = strlen($aMatches[1]); $this->iServicesTokenLocation = $iLocation; break; } $iLocation = ftell($this->fServicesHandle); } if (!$bFound) { fclose($this->fServicesHandle); throw new ConsoleException( 'Services file does not contain the generator token (i.e // GENERATOR[' . $sToken . ']) ' . 'This token is required so that the tool can safely insert new definitions' ); } } else { throw new ConsoleException( 'Failed to open the services file for reading and writing: ' . static::SERVICE_PATH ); } return $this; }
php
protected function validateServiceFile(string $sToken = null): BaseMaker { if (empty($sToken) && empty(static::SERVICE_TOKEN)) { throw new ConsoleException( 'SERVICE_TOKEN is not set' ); } elseif (empty($sToken)) { $sToken = static::SERVICE_TOKEN; } // Detect the services file if (!file_exists(static::SERVICE_PATH)) { throw new ConsoleException( 'Could not detect the app\'s services.php file: ' . static::SERVICE_PATH ); } // Look for the generator token $this->fServicesHandle = fopen(static::SERVICE_PATH, 'r+');; $bFound = false; if ($this->fServicesHandle) { $iLocation = 0; while (($sLine = fgets($this->fServicesHandle)) !== false) { if (preg_match('#^(\s*)// GENERATOR\[' . $sToken . '\]#', $sLine, $aMatches)) { $bFound = true; $this->iServicesIndent = strlen($aMatches[1]); $this->iServicesTokenLocation = $iLocation; break; } $iLocation = ftell($this->fServicesHandle); } if (!$bFound) { fclose($this->fServicesHandle); throw new ConsoleException( 'Services file does not contain the generator token (i.e // GENERATOR[' . $sToken . ']) ' . 'This token is required so that the tool can safely insert new definitions' ); } } else { throw new ConsoleException( 'Failed to open the services file for reading and writing: ' . static::SERVICE_PATH ); } return $this; }
[ "protected", "function", "validateServiceFile", "(", "string", "$", "sToken", "=", "null", ")", ":", "BaseMaker", "{", "if", "(", "empty", "(", "$", "sToken", ")", "&&", "empty", "(", "static", "::", "SERVICE_TOKEN", ")", ")", "{", "throw", "new", "Conso...
Validate the service file is valid @return $this @throws ConsoleException
[ "Validate", "the", "service", "file", "is", "valid" ]
bef013213c914af33172293a386e2738ceedc12d
https://github.com/nails/module-console/blob/bef013213c914af33172293a386e2738ceedc12d/src/Command/BaseMaker.php#L307-L352
train
nails/module-console
src/Command/BaseMaker.php
BaseMaker.writeServiceFile
protected function writeServiceFile(array $aServiceDefinitions = []): BaseMaker { // Create a temporary file $fTempHandle = fopen(static::SERVICE_TEMP_PATH, 'w+'); rewind($this->fServicesHandle); $iLocation = 0; while (($sLine = fgets($this->fServicesHandle)) !== false) { if ($iLocation === $this->iServicesTokenLocation) { fwrite( $fTempHandle, implode("\n", $aServiceDefinitions) . "\n" ); } fwrite($fTempHandle, $sLine); $iLocation = ftell($this->fServicesHandle); } // @todo (Pablo - 2019-02-11) - Sort the services by name // Move the temp services file into place unlink(static::SERVICE_PATH); rename(static::SERVICE_TEMP_PATH, static::SERVICE_PATH); fclose($fTempHandle); fclose($this->fServicesHandle); return $this; }
php
protected function writeServiceFile(array $aServiceDefinitions = []): BaseMaker { // Create a temporary file $fTempHandle = fopen(static::SERVICE_TEMP_PATH, 'w+'); rewind($this->fServicesHandle); $iLocation = 0; while (($sLine = fgets($this->fServicesHandle)) !== false) { if ($iLocation === $this->iServicesTokenLocation) { fwrite( $fTempHandle, implode("\n", $aServiceDefinitions) . "\n" ); } fwrite($fTempHandle, $sLine); $iLocation = ftell($this->fServicesHandle); } // @todo (Pablo - 2019-02-11) - Sort the services by name // Move the temp services file into place unlink(static::SERVICE_PATH); rename(static::SERVICE_TEMP_PATH, static::SERVICE_PATH); fclose($fTempHandle); fclose($this->fServicesHandle); return $this; }
[ "protected", "function", "writeServiceFile", "(", "array", "$", "aServiceDefinitions", "=", "[", "]", ")", ":", "BaseMaker", "{", "// Create a temporary file", "$", "fTempHandle", "=", "fopen", "(", "static", "::", "SERVICE_TEMP_PATH", ",", "'w+'", ")", ";", "r...
Write the definitions to the services file @param array $aServiceDefinitions The definitions to write @return $this
[ "Write", "the", "definitions", "to", "the", "services", "file" ]
bef013213c914af33172293a386e2738ceedc12d
https://github.com/nails/module-console/blob/bef013213c914af33172293a386e2738ceedc12d/src/Command/BaseMaker.php#L363-L389
train
s9e/RegexpBuilder
src/Passes/CoalesceOptionalStrings.php
CoalesceOptionalStrings.buildCoalescedStrings
protected function buildCoalescedStrings(array $prefixStrings, array $suffix) { $strings = $this->runPass($this->buildPrefix($prefixStrings)); if (count($strings) === 1 && $strings[0][0][0] === []) { // If the prefix has been remerged into a list of strings which contains only one string // of which the first element is an optional alternations, we only need to append the // suffix $strings[0][] = $suffix; } else { // Put the current list of strings that form the prefix into a new list of strings, of // which the only string is composed of our optional prefix followed by the suffix array_unshift($strings, []); $strings = [[$strings, $suffix]]; } return $strings; }
php
protected function buildCoalescedStrings(array $prefixStrings, array $suffix) { $strings = $this->runPass($this->buildPrefix($prefixStrings)); if (count($strings) === 1 && $strings[0][0][0] === []) { // If the prefix has been remerged into a list of strings which contains only one string // of which the first element is an optional alternations, we only need to append the // suffix $strings[0][] = $suffix; } else { // Put the current list of strings that form the prefix into a new list of strings, of // which the only string is composed of our optional prefix followed by the suffix array_unshift($strings, []); $strings = [[$strings, $suffix]]; } return $strings; }
[ "protected", "function", "buildCoalescedStrings", "(", "array", "$", "prefixStrings", ",", "array", "$", "suffix", ")", "{", "$", "strings", "=", "$", "this", "->", "runPass", "(", "$", "this", "->", "buildPrefix", "(", "$", "prefixStrings", ")", ")", ";",...
Build the final list of coalesced strings @param array[] $prefixStrings @param array $suffix @return array[]
[ "Build", "the", "final", "list", "of", "coalesced", "strings" ]
59d0167a909659d718f53964f7653d2c83a5f8fe
https://github.com/s9e/RegexpBuilder/blob/59d0167a909659d718f53964f7653d2c83a5f8fe/src/Passes/CoalesceOptionalStrings.php#L50-L69
train
s9e/RegexpBuilder
src/Passes/CoalesceOptionalStrings.php
CoalesceOptionalStrings.buildPrefix
protected function buildPrefix(array $strings) { $prefix = []; foreach ($strings as $string) { // Remove the last element (suffix) of each string before adding it array_pop($string); $prefix[] = $string; } return $prefix; }
php
protected function buildPrefix(array $strings) { $prefix = []; foreach ($strings as $string) { // Remove the last element (suffix) of each string before adding it array_pop($string); $prefix[] = $string; } return $prefix; }
[ "protected", "function", "buildPrefix", "(", "array", "$", "strings", ")", "{", "$", "prefix", "=", "[", "]", ";", "foreach", "(", "$", "strings", "as", "$", "string", ")", "{", "// Remove the last element (suffix) of each string before adding it", "array_pop", "(...
Build the list of strings used as prefix @param array[] $strings @return array[]
[ "Build", "the", "list", "of", "strings", "used", "as", "prefix" ]
59d0167a909659d718f53964f7653d2c83a5f8fe
https://github.com/s9e/RegexpBuilder/blob/59d0167a909659d718f53964f7653d2c83a5f8fe/src/Passes/CoalesceOptionalStrings.php#L77-L88
train
s9e/RegexpBuilder
src/Passes/CoalesceOptionalStrings.php
CoalesceOptionalStrings.buildSuffix
protected function buildSuffix(array $strings) { $suffix = [[]]; foreach ($strings as $string) { if ($this->isCharacterClassString($string)) { foreach ($string[0] as $element) { $suffix[] = $element; } } else { $suffix[] = $string; } } return $suffix; }
php
protected function buildSuffix(array $strings) { $suffix = [[]]; foreach ($strings as $string) { if ($this->isCharacterClassString($string)) { foreach ($string[0] as $element) { $suffix[] = $element; } } else { $suffix[] = $string; } } return $suffix; }
[ "protected", "function", "buildSuffix", "(", "array", "$", "strings", ")", "{", "$", "suffix", "=", "[", "[", "]", "]", ";", "foreach", "(", "$", "strings", "as", "$", "string", ")", "{", "if", "(", "$", "this", "->", "isCharacterClassString", "(", "...
Build a list of strings that matches any given strings or nothing Will unpack groups of single characters @param array[] $strings @return array[]
[ "Build", "a", "list", "of", "strings", "that", "matches", "any", "given", "strings", "or", "nothing" ]
59d0167a909659d718f53964f7653d2c83a5f8fe
https://github.com/s9e/RegexpBuilder/blob/59d0167a909659d718f53964f7653d2c83a5f8fe/src/Passes/CoalesceOptionalStrings.php#L98-L117
train
s9e/RegexpBuilder
src/Passes/CoalesceOptionalStrings.php
CoalesceOptionalStrings.getPrefixGroups
protected function getPrefixGroups(array $strings) { $groups = []; foreach ($strings as $k => $string) { if ($this->hasOptionalSuffix($string)) { $groups[serialize(end($string))][$k] = $string; } } return $groups; }
php
protected function getPrefixGroups(array $strings) { $groups = []; foreach ($strings as $k => $string) { if ($this->hasOptionalSuffix($string)) { $groups[serialize(end($string))][$k] = $string; } } return $groups; }
[ "protected", "function", "getPrefixGroups", "(", "array", "$", "strings", ")", "{", "$", "groups", "=", "[", "]", ";", "foreach", "(", "$", "strings", "as", "$", "k", "=>", "$", "string", ")", "{", "if", "(", "$", "this", "->", "hasOptionalSuffix", "...
Get the list of potential prefix strings grouped by identical suffix @param array[] $strings @return array
[ "Get", "the", "list", "of", "potential", "prefix", "strings", "grouped", "by", "identical", "suffix" ]
59d0167a909659d718f53964f7653d2c83a5f8fe
https://github.com/s9e/RegexpBuilder/blob/59d0167a909659d718f53964f7653d2c83a5f8fe/src/Passes/CoalesceOptionalStrings.php#L125-L137
train
excelwebzone/Omlex
lib/Omlex/URLScheme.php
URLScheme.match
public function match($url) { if (!$this->pattern) { $this->pattern = self::buildPatternFromScheme($this); } return (bool) preg_match($this->pattern, $url); }
php
public function match($url) { if (!$this->pattern) { $this->pattern = self::buildPatternFromScheme($this); } return (bool) preg_match($this->pattern, $url); }
[ "public", "function", "match", "(", "$", "url", ")", "{", "if", "(", "!", "$", "this", "->", "pattern", ")", "{", "$", "this", "->", "pattern", "=", "self", "::", "buildPatternFromScheme", "(", "$", "this", ")", ";", "}", "return", "(", "bool", ")"...
Check whether the given URL match the scheme @param string $url The URL to check against @return Boolean True if match, false if not
[ "Check", "whether", "the", "given", "URL", "match", "the", "scheme" ]
88fa11bf02d1ab364fbc1cba208e82156d5ef784
https://github.com/excelwebzone/Omlex/blob/88fa11bf02d1ab364fbc1cba208e82156d5ef784/lib/Omlex/URLScheme.php#L70-L77
train
excelwebzone/Omlex
lib/Omlex/URLScheme.php
URLScheme.buildPatternFromScheme
static protected function buildPatternFromScheme(URLScheme $scheme) { // generate a unique random string $uniq = md5(mt_rand()); // replace the wildcard sub-domain if exists $scheme = str_replace( '://'.self::WILDCARD_CHARACTER.'.', '://'.$uniq, $scheme->__tostring() ); // replace the wildcards $scheme = str_replace( self::WILDCARD_CHARACTER, $uniq, $scheme ); // set the pattern wrap $wrap = '|'; // quote the pattern $pattern = preg_quote($scheme, $wrap); // replace the unique string by the character class $pattern = str_replace($uniq, '.*', $pattern); return $wrap.$pattern.$wrap.'iu'; }
php
static protected function buildPatternFromScheme(URLScheme $scheme) { // generate a unique random string $uniq = md5(mt_rand()); // replace the wildcard sub-domain if exists $scheme = str_replace( '://'.self::WILDCARD_CHARACTER.'.', '://'.$uniq, $scheme->__tostring() ); // replace the wildcards $scheme = str_replace( self::WILDCARD_CHARACTER, $uniq, $scheme ); // set the pattern wrap $wrap = '|'; // quote the pattern $pattern = preg_quote($scheme, $wrap); // replace the unique string by the character class $pattern = str_replace($uniq, '.*', $pattern); return $wrap.$pattern.$wrap.'iu'; }
[ "static", "protected", "function", "buildPatternFromScheme", "(", "URLScheme", "$", "scheme", ")", "{", "// generate a unique random string", "$", "uniq", "=", "md5", "(", "mt_rand", "(", ")", ")", ";", "// replace the wildcard sub-domain if exists", "$", "scheme", "=...
Builds pattern from scheme @return string
[ "Builds", "pattern", "from", "scheme" ]
88fa11bf02d1ab364fbc1cba208e82156d5ef784
https://github.com/excelwebzone/Omlex/blob/88fa11bf02d1ab364fbc1cba208e82156d5ef784/lib/Omlex/URLScheme.php#L84-L113
train
drdplusinfo/tables
DrdPlus/Tables/Measurements/Experiences/ExperiencesTable.php
ExperiencesTable.toLevel
public function toLevel(Experiences $experiences): Level { $woundsBonus = $this->toWoundsBonus($experiences); return new Level($this->bonusToLevelValue($woundsBonus), $this); }
php
public function toLevel(Experiences $experiences): Level { $woundsBonus = $this->toWoundsBonus($experiences); return new Level($this->bonusToLevelValue($woundsBonus), $this); }
[ "public", "function", "toLevel", "(", "Experiences", "$", "experiences", ")", ":", "Level", "{", "$", "woundsBonus", "=", "$", "this", "->", "toWoundsBonus", "(", "$", "experiences", ")", ";", "return", "new", "Level", "(", "$", "this", "->", "bonusToLevel...
Gives highest level possible, independently on any previous level. @param Experiences $experiences @return Level
[ "Gives", "highest", "level", "possible", "independently", "on", "any", "previous", "level", "." ]
7a577ddbd1748369eec4e84effcc92ffcb54d1f3
https://github.com/drdplusinfo/tables/blob/7a577ddbd1748369eec4e84effcc92ffcb54d1f3/DrdPlus/Tables/Measurements/Experiences/ExperiencesTable.php#L56-L61
train
drdplusinfo/tables
DrdPlus/Tables/Measurements/Experiences/ExperiencesTable.php
ExperiencesTable.toTotalLevel
public function toTotalLevel(Experiences $experiences): Level { $currentExperiences = 0; $usedExperiences = 0; $maxLevelValue = 0; while ($usedExperiences + $currentExperiences <= $experiences->getValue()) { $level = $this->toLevel(new Experiences($currentExperiences, $this)); if ($maxLevelValue < $level->getValue()) { $usedExperiences += $currentExperiences; $maxLevelValue = $level->getValue(); } $currentExperiences++; } return new Level($maxLevelValue, $this); }
php
public function toTotalLevel(Experiences $experiences): Level { $currentExperiences = 0; $usedExperiences = 0; $maxLevelValue = 0; while ($usedExperiences + $currentExperiences <= $experiences->getValue()) { $level = $this->toLevel(new Experiences($currentExperiences, $this)); if ($maxLevelValue < $level->getValue()) { $usedExperiences += $currentExperiences; $maxLevelValue = $level->getValue(); } $currentExperiences++; } return new Level($maxLevelValue, $this); }
[ "public", "function", "toTotalLevel", "(", "Experiences", "$", "experiences", ")", ":", "Level", "{", "$", "currentExperiences", "=", "0", ";", "$", "usedExperiences", "=", "0", ";", "$", "maxLevelValue", "=", "0", ";", "while", "(", "$", "usedExperiences", ...
Leveling sequentially from very first level up to highest possible until all experiences are spent. @param Experiences $experiences @return Level
[ "Leveling", "sequentially", "from", "very", "first", "level", "up", "to", "highest", "possible", "until", "all", "experiences", "are", "spent", "." ]
7a577ddbd1748369eec4e84effcc92ffcb54d1f3
https://github.com/drdplusinfo/tables/blob/7a577ddbd1748369eec4e84effcc92ffcb54d1f3/DrdPlus/Tables/Measurements/Experiences/ExperiencesTable.php#L97-L112
train
drdplusinfo/tables
DrdPlus/Tables/Measurements/Experiences/ExperiencesTable.php
ExperiencesTable.toTotalExperiences
public function toTotalExperiences(Level $level): Experiences { $experiencesSum = 0; for ($levelValueToCast = $level->getValue(); $levelValueToCast > 0; $levelValueToCast--) { if ($levelValueToCast > 1) { // main profession has first level for free $currentLevel = new Level($levelValueToCast, $this); $experiencesSum += $currentLevel->getExperiences()->getValue(); } } return new Experiences($experiencesSum, $this); }
php
public function toTotalExperiences(Level $level): Experiences { $experiencesSum = 0; for ($levelValueToCast = $level->getValue(); $levelValueToCast > 0; $levelValueToCast--) { if ($levelValueToCast > 1) { // main profession has first level for free $currentLevel = new Level($levelValueToCast, $this); $experiencesSum += $currentLevel->getExperiences()->getValue(); } } return new Experiences($experiencesSum, $this); }
[ "public", "function", "toTotalExperiences", "(", "Level", "$", "level", ")", ":", "Experiences", "{", "$", "experiencesSum", "=", "0", ";", "for", "(", "$", "levelValueToCast", "=", "$", "level", "->", "getValue", "(", ")", ";", "$", "levelValueToCast", ">...
Casting level to experiences is mostly lossy conversion! Gives all experiences needed to achieve all levels sequentially up to given. @param Level $level @return Experiences
[ "Casting", "level", "to", "experiences", "is", "mostly", "lossy", "conversion!", "Gives", "all", "experiences", "needed", "to", "achieve", "all", "levels", "sequentially", "up", "to", "given", "." ]
7a577ddbd1748369eec4e84effcc92ffcb54d1f3
https://github.com/drdplusinfo/tables/blob/7a577ddbd1748369eec4e84effcc92ffcb54d1f3/DrdPlus/Tables/Measurements/Experiences/ExperiencesTable.php#L147-L158
train
vanilla/garden-db
src/Db.php
Db.driverClass
public static function driverClass($driver) { if ($driver instanceof PDO) { $name = $driver->getAttribute(PDO::ATTR_DRIVER_NAME); } else { $name = (string)$driver; } $name = strtolower($name); return isset(self::$drivers[$name]) ? self::$drivers[$name] : null; }
php
public static function driverClass($driver) { if ($driver instanceof PDO) { $name = $driver->getAttribute(PDO::ATTR_DRIVER_NAME); } else { $name = (string)$driver; } $name = strtolower($name); return isset(self::$drivers[$name]) ? self::$drivers[$name] : null; }
[ "public", "static", "function", "driverClass", "(", "$", "driver", ")", "{", "if", "(", "$", "driver", "instanceof", "PDO", ")", "{", "$", "name", "=", "$", "driver", "->", "getAttribute", "(", "PDO", "::", "ATTR_DRIVER_NAME", ")", ";", "}", "else", "{...
Get the name of the class that handles a database driver. @param string|PDO $driver The name of the driver or a database connection. @return null|string Returns the driver classname or **null** if one isn't found.
[ "Get", "the", "name", "of", "the", "class", "that", "handles", "a", "database", "driver", "." ]
2634229fb7a161f649ad371e59a973ccbbe72247
https://github.com/vanilla/garden-db/blob/2634229fb7a161f649ad371e59a973ccbbe72247/src/Db.php#L149-L158
train
vanilla/garden-db
src/Db.php
Db.dropTable
final public function dropTable(string $table, array $options = []) { $options += [Db::OPTION_IGNORE => false]; $this->dropTableDb($table, $options); $tableKey = strtolower($table); unset($this->tables[$tableKey], $this->tableNames[$tableKey]); }
php
final public function dropTable(string $table, array $options = []) { $options += [Db::OPTION_IGNORE => false]; $this->dropTableDb($table, $options); $tableKey = strtolower($table); unset($this->tables[$tableKey], $this->tableNames[$tableKey]); }
[ "final", "public", "function", "dropTable", "(", "string", "$", "table", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "+=", "[", "Db", "::", "OPTION_IGNORE", "=>", "false", "]", ";", "$", "this", "->", "dropTableDb", "(", "$...
Drop a table. @param string $table The name of the table to drop. @param array $options An array of additional options when adding the table.
[ "Drop", "a", "table", "." ]
2634229fb7a161f649ad371e59a973ccbbe72247
https://github.com/vanilla/garden-db/blob/2634229fb7a161f649ad371e59a973ccbbe72247/src/Db.php#L185-L191
train
vanilla/garden-db
src/Db.php
Db.fetchTableNames
final public function fetchTableNames() { if ($this->tableNames !== null) { return array_values($this->tableNames); } $names = $this->fetchTableNamesDb(); $this->tableNames = []; foreach ($names as $name) { $name = $this->stripPrefix($name); $this->tableNames[strtolower($name)] = $name; } return array_values($this->tableNames); }
php
final public function fetchTableNames() { if ($this->tableNames !== null) { return array_values($this->tableNames); } $names = $this->fetchTableNamesDb(); $this->tableNames = []; foreach ($names as $name) { $name = $this->stripPrefix($name); $this->tableNames[strtolower($name)] = $name; } return array_values($this->tableNames); }
[ "final", "public", "function", "fetchTableNames", "(", ")", "{", "if", "(", "$", "this", "->", "tableNames", "!==", "null", ")", "{", "return", "array_values", "(", "$", "this", "->", "tableNames", ")", ";", "}", "$", "names", "=", "$", "this", "->", ...
Get the names of all the tables in the database. @return string[] Returns an array of table names without prefixes.
[ "Get", "the", "names", "of", "all", "the", "tables", "in", "the", "database", "." ]
2634229fb7a161f649ad371e59a973ccbbe72247
https://github.com/vanilla/garden-db/blob/2634229fb7a161f649ad371e59a973ccbbe72247/src/Db.php#L206-L220
train
vanilla/garden-db
src/Db.php
Db.fetchTableDef
final public function fetchTableDef(string $table) { $tableKey = strtolower($table); // First check the table cache. if (isset($this->tables[$tableKey])) { $tableDef = $this->tables[$tableKey]; if (isset($tableDef['columns'], $tableDef['indexes'])) { return $tableDef; } } elseif ($this->tableNames !== null && !isset($this->tableNames[$tableKey])) { return null; } $tableDef = $this->fetchTableDefDb($table); if ($tableDef !== null) { $this->fixIndexes($tableDef['name'], $tableDef); $this->tables[$tableKey] = $tableDef; } return $tableDef; }
php
final public function fetchTableDef(string $table) { $tableKey = strtolower($table); // First check the table cache. if (isset($this->tables[$tableKey])) { $tableDef = $this->tables[$tableKey]; if (isset($tableDef['columns'], $tableDef['indexes'])) { return $tableDef; } } elseif ($this->tableNames !== null && !isset($this->tableNames[$tableKey])) { return null; } $tableDef = $this->fetchTableDefDb($table); if ($tableDef !== null) { $this->fixIndexes($tableDef['name'], $tableDef); $this->tables[$tableKey] = $tableDef; } return $tableDef; }
[ "final", "public", "function", "fetchTableDef", "(", "string", "$", "table", ")", "{", "$", "tableKey", "=", "strtolower", "(", "$", "table", ")", ";", "// First check the table cache.", "if", "(", "isset", "(", "$", "this", "->", "tables", "[", "$", "tabl...
Get a table definition. @param string $table The name of the table. @return array|null Returns the table definition or null if the table does not exist.
[ "Get", "a", "table", "definition", "." ]
2634229fb7a161f649ad371e59a973ccbbe72247
https://github.com/vanilla/garden-db/blob/2634229fb7a161f649ad371e59a973ccbbe72247/src/Db.php#L237-L258
train
vanilla/garden-db
src/Db.php
Db.fetchColumnDefs
final public function fetchColumnDefs(string $table) { $tableKey = strtolower($table); if (!empty($this->tables[$tableKey]['columns'])) { $this->tables[$tableKey]['columns']; } elseif ($this->tableNames !== null && !isset($this->tableNames[$tableKey])) { return null; } $columnDefs = $this->fetchColumnDefsDb($table); if ($columnDefs !== null) { $this->tables[$tableKey]['columns'] = $columnDefs; } return $columnDefs; }
php
final public function fetchColumnDefs(string $table) { $tableKey = strtolower($table); if (!empty($this->tables[$tableKey]['columns'])) { $this->tables[$tableKey]['columns']; } elseif ($this->tableNames !== null && !isset($this->tableNames[$tableKey])) { return null; } $columnDefs = $this->fetchColumnDefsDb($table); if ($columnDefs !== null) { $this->tables[$tableKey]['columns'] = $columnDefs; } return $columnDefs; }
[ "final", "public", "function", "fetchColumnDefs", "(", "string", "$", "table", ")", "{", "$", "tableKey", "=", "strtolower", "(", "$", "table", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "tables", "[", "$", "tableKey", "]", "[", "'col...
Get the column definitions for a table. @param string $table The name of the table to get the columns for. @return array|null Returns an array of column definitions.
[ "Get", "the", "column", "definitions", "for", "a", "table", "." ]
2634229fb7a161f649ad371e59a973ccbbe72247
https://github.com/vanilla/garden-db/blob/2634229fb7a161f649ad371e59a973ccbbe72247/src/Db.php#L275-L289
train
vanilla/garden-db
src/Db.php
Db.typeDef
public static function typeDef(string $type) { // Check for the unsigned signifier. $unsigned = null; if ($type[0] === 'u') { $unsigned = true; $type = substr($type, 1); } elseif (preg_match('`(.+)\s+unsigned`i', $type, $m)) { $unsigned = true; $type = $m[1]; } // Remove brackets from the type. $brackets = null; if (preg_match('`^(.*)\((.*)\)$`', $type, $m)) { $brackets = $m[2]; $type = $m[1]; } // Look for the type. $type = strtolower($type); if (isset(self::$types[$type])) { $row = self::$types[$type]; $dbtype = $type; // Resolve an alias. if (is_string($row)) { $dbtype = $row; $row = self::$types[$row]; } } else { return null; } // Now that we have a type row we can build a schema for it. $schema = [ 'type' => $row['type'], 'dbtype' => $dbtype ]; if (!empty($row['schema'])) { $schema += $row['schema']; } if ($row['type'] === 'integer' && $unsigned) { $schema['unsigned'] = true; if (!empty($schema['maximum'])) { $schema['maximum'] = $schema['maximum'] * 2 + 1; $schema['minimum'] = 0; } } if (!empty($row['length'])) { $schema['maxLength'] = (int)$brackets ?: 255; } if (!empty($row['precision'])) { $parts = array_map('trim', explode(',', $brackets)); $schema['precision'] = (int)$parts[0]; if (isset($parts[1])) { $schema['scale'] = (int)$parts[1]; } } if (!empty($row['enum'])) { $enum = explode(',', $brackets); $schema['enum'] = array_map(function ($str) { return trim($str, "'\" \t\n\r\0\x0B"); }, $enum); } return $schema; }
php
public static function typeDef(string $type) { // Check for the unsigned signifier. $unsigned = null; if ($type[0] === 'u') { $unsigned = true; $type = substr($type, 1); } elseif (preg_match('`(.+)\s+unsigned`i', $type, $m)) { $unsigned = true; $type = $m[1]; } // Remove brackets from the type. $brackets = null; if (preg_match('`^(.*)\((.*)\)$`', $type, $m)) { $brackets = $m[2]; $type = $m[1]; } // Look for the type. $type = strtolower($type); if (isset(self::$types[$type])) { $row = self::$types[$type]; $dbtype = $type; // Resolve an alias. if (is_string($row)) { $dbtype = $row; $row = self::$types[$row]; } } else { return null; } // Now that we have a type row we can build a schema for it. $schema = [ 'type' => $row['type'], 'dbtype' => $dbtype ]; if (!empty($row['schema'])) { $schema += $row['schema']; } if ($row['type'] === 'integer' && $unsigned) { $schema['unsigned'] = true; if (!empty($schema['maximum'])) { $schema['maximum'] = $schema['maximum'] * 2 + 1; $schema['minimum'] = 0; } } if (!empty($row['length'])) { $schema['maxLength'] = (int)$brackets ?: 255; } if (!empty($row['precision'])) { $parts = array_map('trim', explode(',', $brackets)); $schema['precision'] = (int)$parts[0]; if (isset($parts[1])) { $schema['scale'] = (int)$parts[1]; } } if (!empty($row['enum'])) { $enum = explode(',', $brackets); $schema['enum'] = array_map(function ($str) { return trim($str, "'\" \t\n\r\0\x0B"); }, $enum); } return $schema; }
[ "public", "static", "function", "typeDef", "(", "string", "$", "type", ")", "{", "// Check for the unsigned signifier.", "$", "unsigned", "=", "null", ";", "if", "(", "$", "type", "[", "0", "]", "===", "'u'", ")", "{", "$", "unsigned", "=", "true", ";", ...
Get the canonical type based on a type string. @param string $type A type string. @return array|null Returns the type schema array or **null** if a type isn't found.
[ "Get", "the", "canonical", "type", "based", "on", "a", "type", "string", "." ]
2634229fb7a161f649ad371e59a973ccbbe72247
https://github.com/vanilla/garden-db/blob/2634229fb7a161f649ad371e59a973ccbbe72247/src/Db.php#L305-L377
train
vanilla/garden-db
src/Db.php
Db.dbType
protected static function dbType(array $typeDef) { $dbtype = $typeDef['dbtype']; if (!empty($typeDef['maxLength'])) { $dbtype .= "({$typeDef['maxLength']})"; } elseif (!empty($typeDef['unsigned'])) { $dbtype = 'u'.$dbtype; } elseif (!empty($typeDef['precision'])) { $dbtype .= "({$typeDef['precision']}"; if (!empty($typeDef['scale'])) { $dbtype .= ",{$typeDef['scale']}"; } $dbtype .= ')'; } elseif (!empty($typeDef['enum'])) { $parts = array_map(function ($str) { return "'{$str}'"; }, $typeDef['enum']); $dbtype .= '('.implode(',', $parts).')'; } return $dbtype; }
php
protected static function dbType(array $typeDef) { $dbtype = $typeDef['dbtype']; if (!empty($typeDef['maxLength'])) { $dbtype .= "({$typeDef['maxLength']})"; } elseif (!empty($typeDef['unsigned'])) { $dbtype = 'u'.$dbtype; } elseif (!empty($typeDef['precision'])) { $dbtype .= "({$typeDef['precision']}"; if (!empty($typeDef['scale'])) { $dbtype .= ",{$typeDef['scale']}"; } $dbtype .= ')'; } elseif (!empty($typeDef['enum'])) { $parts = array_map(function ($str) { return "'{$str}'"; }, $typeDef['enum']); $dbtype .= '('.implode(',', $parts).')'; } return $dbtype; }
[ "protected", "static", "function", "dbType", "(", "array", "$", "typeDef", ")", "{", "$", "dbtype", "=", "$", "typeDef", "[", "'dbtype'", "]", ";", "if", "(", "!", "empty", "(", "$", "typeDef", "[", "'maxLength'", "]", ")", ")", "{", "$", "dbtype", ...
Get the database type string from a type definition. This is the opposite of {@link Db::typeDef()}. @param array $typeDef The type definition array. @return string Returns a db type string.
[ "Get", "the", "database", "type", "string", "from", "a", "type", "definition", "." ]
2634229fb7a161f649ad371e59a973ccbbe72247
https://github.com/vanilla/garden-db/blob/2634229fb7a161f649ad371e59a973ccbbe72247/src/Db.php#L387-L407
train
vanilla/garden-db
src/Db.php
Db.findPrimaryKeyIndex
protected function findPrimaryKeyIndex(array $indexes) { foreach ($indexes as $index) { if ($index['type'] === Db::INDEX_PK) { return $index; } } return null; }
php
protected function findPrimaryKeyIndex(array $indexes) { foreach ($indexes as $index) { if ($index['type'] === Db::INDEX_PK) { return $index; } } return null; }
[ "protected", "function", "findPrimaryKeyIndex", "(", "array", "$", "indexes", ")", "{", "foreach", "(", "$", "indexes", "as", "$", "index", ")", "{", "if", "(", "$", "index", "[", "'type'", "]", "===", "Db", "::", "INDEX_PK", ")", "{", "return", "$", ...
Find the primary key in an array of indexes. @param array $indexes The indexes to search. @return array|null Returns the primary key or **null** if there isn't one.
[ "Find", "the", "primary", "key", "in", "an", "array", "of", "indexes", "." ]
2634229fb7a161f649ad371e59a973ccbbe72247
https://github.com/vanilla/garden-db/blob/2634229fb7a161f649ad371e59a973ccbbe72247/src/Db.php#L526-L533
train
vanilla/garden-db
src/Db.php
Db.fixIndexes
private function fixIndexes(string $tableName, array &$tableDef, $curTableDef = null) { $tableDef += ['indexes' => []]; // Loop through the columns and add the primary key index. $primaryColumns = []; foreach ($tableDef['columns'] as $cname => $cdef) { if (!empty($cdef['primary'])) { $primaryColumns[] = $cname; } } // Massage the primary key index. $primaryFound = false; foreach ($tableDef['indexes'] as &$indexDef) { $indexDef += ['name' => $this->buildIndexName($tableName, $indexDef), 'type' => null]; if ($indexDef['type'] === Db::INDEX_PK) { $primaryFound = true; if (empty($primaryColumns)) { foreach ($indexDef['columns'] as $cname) { $tableDef['columns'][$cname]['primary'] = true; } } elseif (array_diff($primaryColumns, $indexDef['columns'])) { throw new \Exception("There is a mismatch in the primary key index and primary key columns.", 500); } } elseif (isset($curTableDef['indexes'])) { foreach ($curTableDef['indexes'] as $curIndexDef) { if ($this->indexCompare($indexDef, $curIndexDef) === 0) { if (!empty($curIndexDef['name'])) { $indexDef['name'] = $curIndexDef['name']; } break; } } } } if (!$primaryFound && !empty($primaryColumns)) { $tableDef['indexes'][] = [ 'columns' => $primaryColumns, 'type' => Db::INDEX_PK ]; } }
php
private function fixIndexes(string $tableName, array &$tableDef, $curTableDef = null) { $tableDef += ['indexes' => []]; // Loop through the columns and add the primary key index. $primaryColumns = []; foreach ($tableDef['columns'] as $cname => $cdef) { if (!empty($cdef['primary'])) { $primaryColumns[] = $cname; } } // Massage the primary key index. $primaryFound = false; foreach ($tableDef['indexes'] as &$indexDef) { $indexDef += ['name' => $this->buildIndexName($tableName, $indexDef), 'type' => null]; if ($indexDef['type'] === Db::INDEX_PK) { $primaryFound = true; if (empty($primaryColumns)) { foreach ($indexDef['columns'] as $cname) { $tableDef['columns'][$cname]['primary'] = true; } } elseif (array_diff($primaryColumns, $indexDef['columns'])) { throw new \Exception("There is a mismatch in the primary key index and primary key columns.", 500); } } elseif (isset($curTableDef['indexes'])) { foreach ($curTableDef['indexes'] as $curIndexDef) { if ($this->indexCompare($indexDef, $curIndexDef) === 0) { if (!empty($curIndexDef['name'])) { $indexDef['name'] = $curIndexDef['name']; } break; } } } } if (!$primaryFound && !empty($primaryColumns)) { $tableDef['indexes'][] = [ 'columns' => $primaryColumns, 'type' => Db::INDEX_PK ]; } }
[ "private", "function", "fixIndexes", "(", "string", "$", "tableName", ",", "array", "&", "$", "tableDef", ",", "$", "curTableDef", "=", "null", ")", "{", "$", "tableDef", "+=", "[", "'indexes'", "=>", "[", "]", "]", ";", "// Loop through the columns and add ...
Move the primary key index into the correct place for database drivers. @param string $tableName The name of the table. @param array &$tableDef The table definition. @param array|null $curTableDef The current database table def used to resolve conflicts in some names. @throws \Exception Throws an exception when there is a mismatch between the primary index and the primary key defined on the columns themselves.
[ "Move", "the", "primary", "key", "index", "into", "the", "correct", "place", "for", "database", "drivers", "." ]
2634229fb7a161f649ad371e59a973ccbbe72247
https://github.com/vanilla/garden-db/blob/2634229fb7a161f649ad371e59a973ccbbe72247/src/Db.php#L544-L588
train
vanilla/garden-db
src/Db.php
Db.indexCompare
private function indexCompare(array $a, array $b): int { if ($a['columns'] > $b['columns']) { return 1; } elseif ($a['columns'] < $b['columns']) { return -1; } return strcmp( isset($a['type']) ? $a['type'] : '', isset($b['type']) ? $b['type'] : '' ); }
php
private function indexCompare(array $a, array $b): int { if ($a['columns'] > $b['columns']) { return 1; } elseif ($a['columns'] < $b['columns']) { return -1; } return strcmp( isset($a['type']) ? $a['type'] : '', isset($b['type']) ? $b['type'] : '' ); }
[ "private", "function", "indexCompare", "(", "array", "$", "a", ",", "array", "$", "b", ")", ":", "int", "{", "if", "(", "$", "a", "[", "'columns'", "]", ">", "$", "b", "[", "'columns'", "]", ")", "{", "return", "1", ";", "}", "elseif", "(", "$"...
Compare two index definitions to see if they have the same columns and same type. @param array $a The first index. @param array $b The second index. @return int Returns an integer less than, equal to, or greater than zero if {@link $a} is considered to be respectively less than, equal to, or greater than {@link $b}.
[ "Compare", "two", "index", "definitions", "to", "see", "if", "they", "have", "the", "same", "columns", "and", "same", "type", "." ]
2634229fb7a161f649ad371e59a973ccbbe72247
https://github.com/vanilla/garden-db/blob/2634229fb7a161f649ad371e59a973ccbbe72247/src/Db.php#L616-L627
train
vanilla/garden-db
src/Db.php
Db.getOne
final public function getOne($table, array $where, array $options = []) { $rows = $this->get($table, $where, $options); $row = $rows->fetch(); return $row === false ? null : $row; }
php
final public function getOne($table, array $where, array $options = []) { $rows = $this->get($table, $where, $options); $row = $rows->fetch(); return $row === false ? null : $row; }
[ "final", "public", "function", "getOne", "(", "$", "table", ",", "array", "$", "where", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "rows", "=", "$", "this", "->", "get", "(", "$", "table", ",", "$", "where", ",", "$", "options", ...
Get a single row from the database. This is a convenience method that calls {@link Db::get()} and shifts off the first row. @param string|Identifier $table The name of the table to get the data from. @param array $where An array of where conditions. @param array $options An array of additional options. @return array|object|null Returns the row or false if there is no row.
[ "Get", "a", "single", "row", "from", "the", "database", "." ]
2634229fb7a161f649ad371e59a973ccbbe72247
https://github.com/vanilla/garden-db/blob/2634229fb7a161f649ad371e59a973ccbbe72247/src/Db.php#L649-L654
train
vanilla/garden-db
src/Db.php
Db.load
public function load(string $table, $rows, array $options = []) { foreach ($rows as $row) { $this->insert($table, $row, $options); } }
php
public function load(string $table, $rows, array $options = []) { foreach ($rows as $row) { $this->insert($table, $row, $options); } }
[ "public", "function", "load", "(", "string", "$", "table", ",", "$", "rows", ",", "array", "$", "options", "=", "[", "]", ")", "{", "foreach", "(", "$", "rows", "as", "$", "row", ")", "{", "$", "this", "->", "insert", "(", "$", "table", ",", "$...
Load many rows into a table. @param string $table The name of the table to insert into. @param \Traversable|array $rows A dataset to insert. Note that all rows must contain the same columns. The first row will be looked at for the structure of the insert and the rest of the rows will use this structure. @param array $options An array of options for the inserts. See {@link Db::insert()} for details. @see Db::insert()
[ "Load", "many", "rows", "into", "a", "table", "." ]
2634229fb7a161f649ad371e59a973ccbbe72247
https://github.com/vanilla/garden-db/blob/2634229fb7a161f649ad371e59a973ccbbe72247/src/Db.php#L685-L689
train
vanilla/garden-db
src/Db.php
Db.buildIndexName
protected function buildIndexName(string $tableName, array $indexDef): string { $indexDef += ['type' => Db::INDEX_IX, 'suffix' => '']; $type = $indexDef['type']; if ($type === Db::INDEX_PK) { return 'primary'; } $px = self::val($type, [Db::INDEX_IX => 'ix_', Db::INDEX_UNIQUE => 'ux_'], 'ix_'); $sx = $indexDef['suffix']; $result = $px.$tableName.'_'.($sx ?: implode('', $indexDef['columns'])); return $result; }
php
protected function buildIndexName(string $tableName, array $indexDef): string { $indexDef += ['type' => Db::INDEX_IX, 'suffix' => '']; $type = $indexDef['type']; if ($type === Db::INDEX_PK) { return 'primary'; } $px = self::val($type, [Db::INDEX_IX => 'ix_', Db::INDEX_UNIQUE => 'ux_'], 'ix_'); $sx = $indexDef['suffix']; $result = $px.$tableName.'_'.($sx ?: implode('', $indexDef['columns'])); return $result; }
[ "protected", "function", "buildIndexName", "(", "string", "$", "tableName", ",", "array", "$", "indexDef", ")", ":", "string", "{", "$", "indexDef", "+=", "[", "'type'", "=>", "Db", "::", "INDEX_IX", ",", "'suffix'", "=>", "''", "]", ";", "$", "type", ...
Build a standardized index name from an index definition. @param string $tableName The name of the table the index is in. @param array $indexDef The index definition. @return string Returns the index name.
[ "Build", "a", "standardized", "index", "name", "from", "an", "index", "definition", "." ]
2634229fb7a161f649ad371e59a973ccbbe72247
https://github.com/vanilla/garden-db/blob/2634229fb7a161f649ad371e59a973ccbbe72247/src/Db.php#L734-L746
train
vanilla/garden-db
src/Db.php
Db.query
protected function query(string $sql, array $params = [], array $options = []): \PDOStatement { $options += [ Db::OPTION_FETCH_MODE => $this->getFetchArgs() ]; $stm = $this->getPDO()->prepare($sql); if ($options[Db::OPTION_FETCH_MODE]) { $stm->setFetchMode(...(array)$options[Db::OPTION_FETCH_MODE]); } $r = $stm->execute($params); // This is a kludge for those that don't have errors turning into exceptions. if ($r === false) { list($state, $code, $msg) = $stm->errorInfo(); throw new \PDOException($msg, $code); } return $stm; }
php
protected function query(string $sql, array $params = [], array $options = []): \PDOStatement { $options += [ Db::OPTION_FETCH_MODE => $this->getFetchArgs() ]; $stm = $this->getPDO()->prepare($sql); if ($options[Db::OPTION_FETCH_MODE]) { $stm->setFetchMode(...(array)$options[Db::OPTION_FETCH_MODE]); } $r = $stm->execute($params); // This is a kludge for those that don't have errors turning into exceptions. if ($r === false) { list($state, $code, $msg) = $stm->errorInfo(); throw new \PDOException($msg, $code); } return $stm; }
[ "protected", "function", "query", "(", "string", "$", "sql", ",", "array", "$", "params", "=", "[", "]", ",", "array", "$", "options", "=", "[", "]", ")", ":", "\\", "PDOStatement", "{", "$", "options", "+=", "[", "Db", "::", "OPTION_FETCH_MODE", "=>...
Execute a query that fetches data. @param string $sql The query to execute. @param array $params Input parameters for the query. @param array $options Additional options. @return \PDOStatement Returns the result of the query. @throws \PDOException Throws an exception if something went wrong during the query.
[ "Execute", "a", "query", "that", "fetches", "data", "." ]
2634229fb7a161f649ad371e59a973ccbbe72247
https://github.com/vanilla/garden-db/blob/2634229fb7a161f649ad371e59a973ccbbe72247/src/Db.php#L757-L778
train
vanilla/garden-db
src/Db.php
Db.queryModify
protected function queryModify(string $sql, array $params = [], array $options = []): int { $options += [Db::OPTION_FETCH_MODE => 0]; $stm = $this->query($sql, $params, $options); return $stm->rowCount(); }
php
protected function queryModify(string $sql, array $params = [], array $options = []): int { $options += [Db::OPTION_FETCH_MODE => 0]; $stm = $this->query($sql, $params, $options); return $stm->rowCount(); }
[ "protected", "function", "queryModify", "(", "string", "$", "sql", ",", "array", "$", "params", "=", "[", "]", ",", "array", "$", "options", "=", "[", "]", ")", ":", "int", "{", "$", "options", "+=", "[", "Db", "::", "OPTION_FETCH_MODE", "=>", "0", ...
Query the database and return a row count. @param string $sql The query to execute. @param array $params Input parameters for the query. @param array $options Additional options. @return int
[ "Query", "the", "database", "and", "return", "a", "row", "count", "." ]
2634229fb7a161f649ad371e59a973ccbbe72247
https://github.com/vanilla/garden-db/blob/2634229fb7a161f649ad371e59a973ccbbe72247/src/Db.php#L788-L792
train
vanilla/garden-db
src/Db.php
Db.queryID
protected function queryID(string $sql, array $params = [], array $options = []) { $options += [Db::OPTION_FETCH_MODE => 0]; $this->query($sql, $params, $options); $r = $this->getPDO()->lastInsertId(); return is_numeric($r) ? (int)$r : $r; }
php
protected function queryID(string $sql, array $params = [], array $options = []) { $options += [Db::OPTION_FETCH_MODE => 0]; $this->query($sql, $params, $options); $r = $this->getPDO()->lastInsertId(); return is_numeric($r) ? (int)$r : $r; }
[ "protected", "function", "queryID", "(", "string", "$", "sql", ",", "array", "$", "params", "=", "[", "]", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "+=", "[", "Db", "::", "OPTION_FETCH_MODE", "=>", "0", "]", ";", "$", ...
Query the database and return the ID of the record that was inserted. @param string $sql The query to execute. @param array $params Input parameters for the query. @param array $options Additional options. @return mixed Returns the record ID.
[ "Query", "the", "database", "and", "return", "the", "ID", "of", "the", "record", "that", "was", "inserted", "." ]
2634229fb7a161f649ad371e59a973ccbbe72247
https://github.com/vanilla/garden-db/blob/2634229fb7a161f649ad371e59a973ccbbe72247/src/Db.php#L802-L808
train
vanilla/garden-db
src/Db.php
Db.queryDefine
protected function queryDefine(string $sql, array $options = []) { $options += [Db::OPTION_FETCH_MODE => 0]; $this->query($sql, [], $options); }
php
protected function queryDefine(string $sql, array $options = []) { $options += [Db::OPTION_FETCH_MODE => 0]; $this->query($sql, [], $options); }
[ "protected", "function", "queryDefine", "(", "string", "$", "sql", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "+=", "[", "Db", "::", "OPTION_FETCH_MODE", "=>", "0", "]", ";", "$", "this", "->", "query", "(", "$", "sql", ...
Query the database for a database define. @param string $sql The query to execute. @param array $options Additional options.
[ "Query", "the", "database", "for", "a", "database", "define", "." ]
2634229fb7a161f649ad371e59a973ccbbe72247
https://github.com/vanilla/garden-db/blob/2634229fb7a161f649ad371e59a973ccbbe72247/src/Db.php#L816-L819
train
vanilla/garden-db
src/Db.php
Db.escape
public function escape($identifier): string { if ($identifier instanceof Literal) { return $identifier->getValue($this); } return '`'.str_replace('`', '``', $identifier).'`'; }
php
public function escape($identifier): string { if ($identifier instanceof Literal) { return $identifier->getValue($this); } return '`'.str_replace('`', '``', $identifier).'`'; }
[ "public", "function", "escape", "(", "$", "identifier", ")", ":", "string", "{", "if", "(", "$", "identifier", "instanceof", "Literal", ")", "{", "return", "$", "identifier", "->", "getValue", "(", "$", "this", ")", ";", "}", "return", "'`'", ".", "str...
Escape an identifier. @param string|Literal $identifier The identifier to escape. @return string Returns the field properly escaped.
[ "Escape", "an", "identifier", "." ]
2634229fb7a161f649ad371e59a973ccbbe72247
https://github.com/vanilla/garden-db/blob/2634229fb7a161f649ad371e59a973ccbbe72247/src/Db.php#L867-L872
train
vanilla/garden-db
src/Db.php
Db.prefixTable
protected function prefixTable($table, bool $escape = true): string { if ($table instanceof Identifier) { return $escape ? $table->escape($this) : (string)$table; } else { $table = $this->px.$table; return $escape ? $this->escape($table) : $table; } }
php
protected function prefixTable($table, bool $escape = true): string { if ($table instanceof Identifier) { return $escape ? $table->escape($this) : (string)$table; } else { $table = $this->px.$table; return $escape ? $this->escape($table) : $table; } }
[ "protected", "function", "prefixTable", "(", "$", "table", ",", "bool", "$", "escape", "=", "true", ")", ":", "string", "{", "if", "(", "$", "table", "instanceof", "Identifier", ")", "{", "return", "$", "escape", "?", "$", "table", "->", "escape", "(",...
Prefix a table name. @param string|Identifier $table The name of the table to prefix. @param bool $escape Whether or not to escape the output. @return string Returns a full table name.
[ "Prefix", "a", "table", "name", "." ]
2634229fb7a161f649ad371e59a973ccbbe72247
https://github.com/vanilla/garden-db/blob/2634229fb7a161f649ad371e59a973ccbbe72247/src/Db.php#L891-L898
train
vanilla/garden-db
src/Db.php
Db.stripPrefix
protected function stripPrefix(string $table): string { $len = strlen($this->px); if (strcasecmp(substr($table, 0, $len), $this->px) === 0) { $table = substr($table, $len); } return $table; }
php
protected function stripPrefix(string $table): string { $len = strlen($this->px); if (strcasecmp(substr($table, 0, $len), $this->px) === 0) { $table = substr($table, $len); } return $table; }
[ "protected", "function", "stripPrefix", "(", "string", "$", "table", ")", ":", "string", "{", "$", "len", "=", "strlen", "(", "$", "this", "->", "px", ")", ";", "if", "(", "strcasecmp", "(", "substr", "(", "$", "table", ",", "0", ",", "$", "len", ...
Strip the database prefix off a table name. @param string $table The name of the table to strip. @return string Returns the table name stripped of the prefix.
[ "Strip", "the", "database", "prefix", "off", "a", "table", "name", "." ]
2634229fb7a161f649ad371e59a973ccbbe72247
https://github.com/vanilla/garden-db/blob/2634229fb7a161f649ad371e59a973ccbbe72247/src/Db.php#L906-L912
train
ommu/mod-core
ommu/ThemeHandle.php
ThemeHandle.getThemesFromDir
public function getThemesFromDir() { $themeList = array(); $themePath = Yii::getPathOfAlias('webroot.themes'); $themes = scandir($themePath); foreach($themes as $theme) { $themeName = $this->urlTitle($theme); $themeFile = $themePath.'/'.$theme.'/'.$themeName.'.yaml'; if(file_exists($themeFile)) { if(!in_array($themeName, $this->getIgnoreTheme())) { $themeList[] = $theme; } } } if(count($themeList) > 0) return $themeList; else return false; }
php
public function getThemesFromDir() { $themeList = array(); $themePath = Yii::getPathOfAlias('webroot.themes'); $themes = scandir($themePath); foreach($themes as $theme) { $themeName = $this->urlTitle($theme); $themeFile = $themePath.'/'.$theme.'/'.$themeName.'.yaml'; if(file_exists($themeFile)) { if(!in_array($themeName, $this->getIgnoreTheme())) { $themeList[] = $theme; } } } if(count($themeList) > 0) return $themeList; else return false; }
[ "public", "function", "getThemesFromDir", "(", ")", "{", "$", "themeList", "=", "array", "(", ")", ";", "$", "themePath", "=", "Yii", "::", "getPathOfAlias", "(", "'webroot.themes'", ")", ";", "$", "themes", "=", "scandir", "(", "$", "themePath", ")", ";...
Mendapatkan daftar theme dari folder themes. @return array daftar theme yang ada atau false jika tidak terdapat theme.
[ "Mendapatkan", "daftar", "theme", "dari", "folder", "themes", "." ]
68c90e76440e74ee93bcf82905a54d86c941b771
https://github.com/ommu/mod-core/blob/68c90e76440e74ee93bcf82905a54d86c941b771/ommu/ThemeHandle.php#L61-L80
train
ommu/mod-core
ommu/ThemeHandle.php
ThemeHandle.cacheThemeConfig
public function cacheThemeConfig($return=false) { $themes = $this->getThemesFromDb(); $arrayTheme = array(); foreach($themes as $theme) { if(!in_array($theme->folder, $arrayTheme)) $arrayTheme[] = $theme->folder; } if($return == false) { $filePath = Yii::getPathOfAlias('application.config'); $fileHandle = fopen($filePath.'/cache_theme.php', 'w'); fwrite($fileHandle, implode("\n", $arrayTheme)); fclose($fileHandle); } else return $arrayTheme; }
php
public function cacheThemeConfig($return=false) { $themes = $this->getThemesFromDb(); $arrayTheme = array(); foreach($themes as $theme) { if(!in_array($theme->folder, $arrayTheme)) $arrayTheme[] = $theme->folder; } if($return == false) { $filePath = Yii::getPathOfAlias('application.config'); $fileHandle = fopen($filePath.'/cache_theme.php', 'w'); fwrite($fileHandle, implode("\n", $arrayTheme)); fclose($fileHandle); } else return $arrayTheme; }
[ "public", "function", "cacheThemeConfig", "(", "$", "return", "=", "false", ")", "{", "$", "themes", "=", "$", "this", "->", "getThemesFromDb", "(", ")", ";", "$", "arrayTheme", "=", "array", "(", ")", ";", "foreach", "(", "$", "themes", "as", "$", "...
Cache theme dari database ke bentuk file. Untuk mengurangi query pada saat install ke database.
[ "Cache", "theme", "dari", "database", "ke", "bentuk", "file", ".", "Untuk", "mengurangi", "query", "pada", "saat", "install", "ke", "database", "." ]
68c90e76440e74ee93bcf82905a54d86c941b771
https://github.com/ommu/mod-core/blob/68c90e76440e74ee93bcf82905a54d86c941b771/ommu/ThemeHandle.php#L86-L104
train
ommu/mod-core
ommu/ThemeHandle.php
ThemeHandle.getThemeConfig
public function getThemeConfig($theme) { Yii::import('mustangostang.spyc.Spyc'); define('DS', DIRECTORY_SEPARATOR); $themeName = $this->urlTitle($theme); $configPath = Yii::getPathOfAlias('webroot.themes.'.$theme).DS.$themeName.'.yaml'; if(file_exists($configPath)) return Spyc::YAMLLoad($configPath); else return null; }
php
public function getThemeConfig($theme) { Yii::import('mustangostang.spyc.Spyc'); define('DS', DIRECTORY_SEPARATOR); $themeName = $this->urlTitle($theme); $configPath = Yii::getPathOfAlias('webroot.themes.'.$theme).DS.$themeName.'.yaml'; if(file_exists($configPath)) return Spyc::YAMLLoad($configPath); else return null; }
[ "public", "function", "getThemeConfig", "(", "$", "theme", ")", "{", "Yii", "::", "import", "(", "'mustangostang.spyc.Spyc'", ")", ";", "define", "(", "'DS'", ",", "DIRECTORY_SEPARATOR", ")", ";", "$", "themeName", "=", "$", "this", "->", "urlTitle", "(", ...
Get theme config from yaml file @param string $theme @return array
[ "Get", "theme", "config", "from", "yaml", "file" ]
68c90e76440e74ee93bcf82905a54d86c941b771
https://github.com/ommu/mod-core/blob/68c90e76440e74ee93bcf82905a54d86c941b771/ommu/ThemeHandle.php#L112-L124
train
ommu/mod-core
ommu/ThemeHandle.php
ThemeHandle.deleteThemeDb
public function deleteThemeDb($theme) { if($theme != null) { $model = OmmuThemes::model()->findByAttributes(array('folder'=>$theme)); if($model != null) $model->delete(); else return false; } else return false; }
php
public function deleteThemeDb($theme) { if($theme != null) { $model = OmmuThemes::model()->findByAttributes(array('folder'=>$theme)); if($model != null) $model->delete(); else return false; } else return false; }
[ "public", "function", "deleteThemeDb", "(", "$", "theme", ")", "{", "if", "(", "$", "theme", "!=", "null", ")", "{", "$", "model", "=", "OmmuThemes", "::", "model", "(", ")", "->", "findByAttributes", "(", "array", "(", "'folder'", "=>", "$", "theme", ...
Delete DB folder
[ "Delete", "DB", "folder" ]
68c90e76440e74ee93bcf82905a54d86c941b771
https://github.com/ommu/mod-core/blob/68c90e76440e74ee93bcf82905a54d86c941b771/ommu/ThemeHandle.php#L129-L141
train
ommu/mod-core
ommu/ThemeHandle.php
ThemeHandle.setThemes
public function setThemes() { $installedTheme = $this->getThemesFromDir(); $cacheTheme = file(Yii::getPathOfAlias('application.config').'/cache_theme.php'); $toBeInstalled = array(); $caches = array(); foreach($cacheTheme as $val) { $caches[] = $val; } if(!$installedTheme) $installedTheme = array(); foreach($caches as $cache) { $cache = trim($cache); if(!in_array($cache, array_map("trim", $installedTheme))) { $this->deleteTheme($cache, true); } } $themeDb = $this->cacheThemeConfig(true); foreach($installedTheme as $theme) { if(!in_array(trim($theme), array_map("trim", $themeDb))) { $config = $this->getThemeConfig($theme); $themeName = $this->urlTitle($theme); if($config && $themeName == $config['folder']) { $model=new OmmuThemes; $model->group_page = $config['group_page']; $model->folder = $theme; $model->layout = $config['layout']; $model->name = $config['name']; $model->thumbnail = $config['thumbnail']; $model->save(); } } } }
php
public function setThemes() { $installedTheme = $this->getThemesFromDir(); $cacheTheme = file(Yii::getPathOfAlias('application.config').'/cache_theme.php'); $toBeInstalled = array(); $caches = array(); foreach($cacheTheme as $val) { $caches[] = $val; } if(!$installedTheme) $installedTheme = array(); foreach($caches as $cache) { $cache = trim($cache); if(!in_array($cache, array_map("trim", $installedTheme))) { $this->deleteTheme($cache, true); } } $themeDb = $this->cacheThemeConfig(true); foreach($installedTheme as $theme) { if(!in_array(trim($theme), array_map("trim", $themeDb))) { $config = $this->getThemeConfig($theme); $themeName = $this->urlTitle($theme); if($config && $themeName == $config['folder']) { $model=new OmmuThemes; $model->group_page = $config['group_page']; $model->folder = $theme; $model->layout = $config['layout']; $model->name = $config['name']; $model->thumbnail = $config['thumbnail']; $model->save(); } } } }
[ "public", "function", "setThemes", "(", ")", "{", "$", "installedTheme", "=", "$", "this", "->", "getThemesFromDir", "(", ")", ";", "$", "cacheTheme", "=", "file", "(", "Yii", "::", "getPathOfAlias", "(", "'application.config'", ")", ".", "'/cache_theme.php'",...
Install theme ke database
[ "Install", "theme", "ke", "database" ]
68c90e76440e74ee93bcf82905a54d86c941b771
https://github.com/ommu/mod-core/blob/68c90e76440e74ee93bcf82905a54d86c941b771/ommu/ThemeHandle.php#L180-L218
train
mirko-pagliai/me-cms
src/Model/Table/PhotosAlbumsTable.php
PhotosAlbumsTable.afterSave
public function afterSave(Event $event, Entity $entity, ArrayObject $options) { //Creates the folder (new Folder($entity->path, true, 0777)); parent::afterSave($event, $entity, $options); }
php
public function afterSave(Event $event, Entity $entity, ArrayObject $options) { //Creates the folder (new Folder($entity->path, true, 0777)); parent::afterSave($event, $entity, $options); }
[ "public", "function", "afterSave", "(", "Event", "$", "event", ",", "Entity", "$", "entity", ",", "ArrayObject", "$", "options", ")", "{", "//Creates the folder", "(", "new", "Folder", "(", "$", "entity", "->", "path", ",", "true", ",", "0777", ")", ")",...
Called after an entity is saved @param \Cake\Event\Event $event Event object @param \Cake\ORM\Entity $entity Entity object @param \ArrayObject $options Options @return void @uses MeCms\Model\Table\AppTable::afterSave()
[ "Called", "after", "an", "entity", "is", "saved" ]
df668ad8e3ee221497c47578d474e487f24ce92a
https://github.com/mirko-pagliai/me-cms/blob/df668ad8e3ee221497c47578d474e487f24ce92a/src/Model/Table/PhotosAlbumsTable.php#L59-L65
train
mirko-pagliai/me-cms
src/Command/Install/CreateAdminCommand.php
CreateAdminCommand.execute
public function execute(Arguments $args, ConsoleIo $io) { $command = new AddUserCommand; return $command->run(['--group', 1] + $args->getOptions(), $io); }
php
public function execute(Arguments $args, ConsoleIo $io) { $command = new AddUserCommand; return $command->run(['--group', 1] + $args->getOptions(), $io); }
[ "public", "function", "execute", "(", "Arguments", "$", "args", ",", "ConsoleIo", "$", "io", ")", "{", "$", "command", "=", "new", "AddUserCommand", ";", "return", "$", "command", "->", "run", "(", "[", "'--group'", ",", "1", "]", "+", "$", "args", "...
Creates an admin user @param Arguments $args The command arguments @param ConsoleIo $io The console io @return null|int The exit code or null for success
[ "Creates", "an", "admin", "user" ]
df668ad8e3ee221497c47578d474e487f24ce92a
https://github.com/mirko-pagliai/me-cms/blob/df668ad8e3ee221497c47578d474e487f24ce92a/src/Command/Install/CreateAdminCommand.php#L45-L50
train
TuumPHP/Respond
src/Helper/ReqAttr.php
ReqAttr.getReferrer
public static function getReferrer(ServerRequestInterface $request) { if ($referrer = $request->getAttribute(self::REFERRER)) { return $referrer; } if ($referrer = Respond::session()->get(self::REFERRER)) { return $referrer; } $info = $request->getServerParams(); return array_key_exists('HTTP_REFERER', $info) ? $info['HTTP_REFERER'] : ''; }
php
public static function getReferrer(ServerRequestInterface $request) { if ($referrer = $request->getAttribute(self::REFERRER)) { return $referrer; } if ($referrer = Respond::session()->get(self::REFERRER)) { return $referrer; } $info = $request->getServerParams(); return array_key_exists('HTTP_REFERER', $info) ? $info['HTTP_REFERER'] : ''; }
[ "public", "static", "function", "getReferrer", "(", "ServerRequestInterface", "$", "request", ")", "{", "if", "(", "$", "referrer", "=", "$", "request", "->", "getAttribute", "(", "self", "::", "REFERRER", ")", ")", "{", "return", "$", "referrer", ";", "}"...
get the referrer uri set by withReferrer, or the HTTP_REFERER if not set. @param ServerRequestInterface $request @return string
[ "get", "the", "referrer", "uri", "set", "by", "withReferrer", "or", "the", "HTTP_REFERER", "if", "not", "set", "." ]
5861ec0bffc97c500d88bf307a53277f1c2fe12f
https://github.com/TuumPHP/Respond/blob/5861ec0bffc97c500d88bf307a53277f1c2fe12f/src/Helper/ReqAttr.php#L39-L50
train
TuumPHP/Respond
src/Helper/ReqAttr.php
ReqAttr.withBasePath
public static function withBasePath(ServerRequestInterface $request, $basePath, $pathInfo = null) { $path = $request->getUri()->getPath(); if (strpos($path, $basePath) !== 0) { throw new \InvalidArgumentException; } $pathInfo = is_null($pathInfo) ? substr($path, strlen($basePath)) : $pathInfo; return $request ->withAttribute(self::BASE_PATH, $basePath) ->withAttribute(self::PATH_INFO, $pathInfo); }
php
public static function withBasePath(ServerRequestInterface $request, $basePath, $pathInfo = null) { $path = $request->getUri()->getPath(); if (strpos($path, $basePath) !== 0) { throw new \InvalidArgumentException; } $pathInfo = is_null($pathInfo) ? substr($path, strlen($basePath)) : $pathInfo; return $request ->withAttribute(self::BASE_PATH, $basePath) ->withAttribute(self::PATH_INFO, $pathInfo); }
[ "public", "static", "function", "withBasePath", "(", "ServerRequestInterface", "$", "request", ",", "$", "basePath", ",", "$", "pathInfo", "=", "null", ")", "{", "$", "path", "=", "$", "request", "->", "getUri", "(", ")", "->", "getPath", "(", ")", ";", ...
set a base-path and path-info for matching. @param ServerRequestInterface $request @param string $basePath @param string|null $pathInfo @return ServerRequestInterface
[ "set", "a", "base", "-", "path", "and", "path", "-", "info", "for", "matching", "." ]
5861ec0bffc97c500d88bf307a53277f1c2fe12f
https://github.com/TuumPHP/Respond/blob/5861ec0bffc97c500d88bf307a53277f1c2fe12f/src/Helper/ReqAttr.php#L60-L71
train
TuumPHP/Respond
src/Helper/ReqAttr.php
ReqAttr.getPathInfo
public static function getPathInfo(ServerRequestInterface $request) { return $request->getAttribute(self::PATH_INFO, null) ?: $request->getUri()->getPath(); }
php
public static function getPathInfo(ServerRequestInterface $request) { return $request->getAttribute(self::PATH_INFO, null) ?: $request->getUri()->getPath(); }
[ "public", "static", "function", "getPathInfo", "(", "ServerRequestInterface", "$", "request", ")", "{", "return", "$", "request", "->", "getAttribute", "(", "self", "::", "PATH_INFO", ",", "null", ")", "?", ":", "$", "request", "->", "getUri", "(", ")", "-...
get a path-info, or uri's path if not set. @param ServerRequestInterface $request @return string
[ "get", "a", "path", "-", "info", "or", "uri", "s", "path", "if", "not", "set", "." ]
5861ec0bffc97c500d88bf307a53277f1c2fe12f
https://github.com/TuumPHP/Respond/blob/5861ec0bffc97c500d88bf307a53277f1c2fe12f/src/Helper/ReqAttr.php#L90-L93
train
Kuestenschmiede/QueueBundle
Classes/Queue/QueueManager.php
QueueManager.run
public function run($eventname, $count) { $queueEvents = $this->loadQueue($eventname, $count); if ($queueEvents->numRows) { while ($queueEvents->next()) { if ($this->checkInterval($queueEvents)) { $this->setStartTime($queueEvents->id); $jobEvent = $this->dispatch($queueEvents); $this->setEndTime($queueEvents->id, $queueEvents->intervaltorun); $this->saveJobResult($queueEvents->id, $jobEvent); } } } else { $this->response($eventname, 'noActiveJobs', 'INFO'); } }
php
public function run($eventname, $count) { $queueEvents = $this->loadQueue($eventname, $count); if ($queueEvents->numRows) { while ($queueEvents->next()) { if ($this->checkInterval($queueEvents)) { $this->setStartTime($queueEvents->id); $jobEvent = $this->dispatch($queueEvents); $this->setEndTime($queueEvents->id, $queueEvents->intervaltorun); $this->saveJobResult($queueEvents->id, $jobEvent); } } } else { $this->response($eventname, 'noActiveJobs', 'INFO'); } }
[ "public", "function", "run", "(", "$", "eventname", ",", "$", "count", ")", "{", "$", "queueEvents", "=", "$", "this", "->", "loadQueue", "(", "$", "eventname", ",", "$", "count", ")", ";", "if", "(", "$", "queueEvents", "->", "numRows", ")", "{", ...
Startet die Verarbeitung der Events eines Types der Queue. @param $eventname @param $count
[ "Startet", "die", "Verarbeitung", "der", "Events", "eines", "Types", "der", "Queue", "." ]
6a81c16ed17fed888ab96bcdc971357381477ef6
https://github.com/Kuestenschmiede/QueueBundle/blob/6a81c16ed17fed888ab96bcdc971357381477ef6/Classes/Queue/QueueManager.php#L101-L117
train
Kuestenschmiede/QueueBundle
Classes/Queue/QueueManager.php
QueueManager.setError
protected function setError($id) { $queueEvent = new QueueSetErrorEvent(); $queueEvent->setId($id); $this->dispatcher->dispatch($queueEvent::NAME, $queueEvent); }
php
protected function setError($id) { $queueEvent = new QueueSetErrorEvent(); $queueEvent->setId($id); $this->dispatcher->dispatch($queueEvent::NAME, $queueEvent); }
[ "protected", "function", "setError", "(", "$", "id", ")", "{", "$", "queueEvent", "=", "new", "QueueSetErrorEvent", "(", ")", ";", "$", "queueEvent", "->", "setId", "(", "$", "id", ")", ";", "$", "this", "->", "dispatcher", "->", "dispatch", "(", "$", ...
Setzt die Endzeit der Verarbeitung eines Eintrags in der Queue. @param $id
[ "Setzt", "die", "Endzeit", "der", "Verarbeitung", "eines", "Eintrags", "in", "der", "Queue", "." ]
6a81c16ed17fed888ab96bcdc971357381477ef6
https://github.com/Kuestenschmiede/QueueBundle/blob/6a81c16ed17fed888ab96bcdc971357381477ef6/Classes/Queue/QueueManager.php#L203-L208
train
Kuestenschmiede/QueueBundle
Classes/Queue/QueueManager.php
QueueManager.saveJobResult
protected function saveJobResult($id, $jobEvent) { if ($jobEvent) { $queueEvent = new QueueSaveJobResultEvent(); $queueEvent->setId($id); $queueEvent->setData($jobEvent); $this->dispatcher->dispatch($queueEvent::NAME, $queueEvent); } }
php
protected function saveJobResult($id, $jobEvent) { if ($jobEvent) { $queueEvent = new QueueSaveJobResultEvent(); $queueEvent->setId($id); $queueEvent->setData($jobEvent); $this->dispatcher->dispatch($queueEvent::NAME, $queueEvent); } }
[ "protected", "function", "saveJobResult", "(", "$", "id", ",", "$", "jobEvent", ")", "{", "if", "(", "$", "jobEvent", ")", "{", "$", "queueEvent", "=", "new", "QueueSaveJobResultEvent", "(", ")", ";", "$", "queueEvent", "->", "setId", "(", "$", "id", "...
Speichernt das verarbeitete Event in der Queue, damit die Fehlermeldungen erhalten bleiben. @param $id @param $jobEvent
[ "Speichernt", "das", "verarbeitete", "Event", "in", "der", "Queue", "damit", "die", "Fehlermeldungen", "erhalten", "bleiben", "." ]
6a81c16ed17fed888ab96bcdc971357381477ef6
https://github.com/Kuestenschmiede/QueueBundle/blob/6a81c16ed17fed888ab96bcdc971357381477ef6/Classes/Queue/QueueManager.php#L216-L224
train
Kuestenschmiede/QueueBundle
Classes/Queue/QueueManager.php
QueueManager.dispatch
protected function dispatch($queueEvent) { $event = urldecode($queueEvent->data); $event = unserialize($event); if ($event) { $this->dispatcher->dispatch($event::NAME, $event); if ($event->getHasError()) { $this->setError($queueEvent->id); $this->response($event::NAME, $event->getError(), 'ERROR', $event->getParam()); } else { $this->response($event::NAME, $event->getReturnMessages(), 'NOTICE', $event->getParam()); } return $event; } }
php
protected function dispatch($queueEvent) { $event = urldecode($queueEvent->data); $event = unserialize($event); if ($event) { $this->dispatcher->dispatch($event::NAME, $event); if ($event->getHasError()) { $this->setError($queueEvent->id); $this->response($event::NAME, $event->getError(), 'ERROR', $event->getParam()); } else { $this->response($event::NAME, $event->getReturnMessages(), 'NOTICE', $event->getParam()); } return $event; } }
[ "protected", "function", "dispatch", "(", "$", "queueEvent", ")", "{", "$", "event", "=", "urldecode", "(", "$", "queueEvent", "->", "data", ")", ";", "$", "event", "=", "unserialize", "(", "$", "event", ")", ";", "if", "(", "$", "event", ")", "{", ...
Ruft die Verarbeitung eines Events der Queue auf. @param $queueEvent @return array
[ "Ruft", "die", "Verarbeitung", "eines", "Events", "der", "Queue", "auf", "." ]
6a81c16ed17fed888ab96bcdc971357381477ef6
https://github.com/Kuestenschmiede/QueueBundle/blob/6a81c16ed17fed888ab96bcdc971357381477ef6/Classes/Queue/QueueManager.php#L232-L249
train
PitonCMS/Engine
app/Models/MessageMapper.php
MessageMapper.markAsRead
public function markAsRead(int $messageId) { $this->sql = 'update message set is_read = \'Y\' where id = ?'; $this->bindValues[] = $messageId; return $this->execute(); }
php
public function markAsRead(int $messageId) { $this->sql = 'update message set is_read = \'Y\' where id = ?'; $this->bindValues[] = $messageId; return $this->execute(); }
[ "public", "function", "markAsRead", "(", "int", "$", "messageId", ")", "{", "$", "this", "->", "sql", "=", "'update message set is_read = \\'Y\\' where id = ?'", ";", "$", "this", "->", "bindValues", "[", "]", "=", "$", "messageId", ";", "return", "$", "this",...
Mark As Read @param int $messageId @return void
[ "Mark", "As", "Read" ]
51622658cbd21946757abc27f6928cb482384659
https://github.com/PitonCMS/Engine/blob/51622658cbd21946757abc27f6928cb482384659/app/Models/MessageMapper.php#L76-L82
train
PitonCMS/Engine
app/Models/MessageMapper.php
MessageMapper.markAsUnread
public function markAsUnread(int $messageId) { $this->sql = 'update message set is_read = \'N\' where id = ?'; $this->bindValues[] = $messageId; return $this->execute(); }
php
public function markAsUnread(int $messageId) { $this->sql = 'update message set is_read = \'N\' where id = ?'; $this->bindValues[] = $messageId; return $this->execute(); }
[ "public", "function", "markAsUnread", "(", "int", "$", "messageId", ")", "{", "$", "this", "->", "sql", "=", "'update message set is_read = \\'N\\' where id = ?'", ";", "$", "this", "->", "bindValues", "[", "]", "=", "$", "messageId", ";", "return", "$", "this...
Mark As Unread @param int $messageId @return void
[ "Mark", "As", "Unread" ]
51622658cbd21946757abc27f6928cb482384659
https://github.com/PitonCMS/Engine/blob/51622658cbd21946757abc27f6928cb482384659/app/Models/MessageMapper.php#L90-L96
train
krixon/datetime
src/DateInterval.php
DateInterval.fromSpecification
public static function fromSpecification(string $specification) : self { $microseconds = 0; // Parse the microsecond component. if (false !== ($position = stripos($specification, 'U'))) { // Step backwards consuming digits until we hit a duration designator. // Note that we always expect at least the duration designator (P), but for loop safety we break if // the first character in the specification is reached too. $microseconds = ''; while ($position > 0) { $char = $specification[--$position]; if (!is_numeric($char)) { break; } $microseconds = $char . $microseconds; } // Remove the microsecond designator from the specification. $specification = substr($specification, 0, -1 - strlen($microseconds)); } // If the specification is just the duration designator it means that only microseconds were specified. // In that case we create an empty interval for convenience. if ('P' === $specification || 'PT' === $specification) { $specification = 'P0Y'; } return new static(new \DateInterval($specification), (int)$microseconds); }
php
public static function fromSpecification(string $specification) : self { $microseconds = 0; // Parse the microsecond component. if (false !== ($position = stripos($specification, 'U'))) { // Step backwards consuming digits until we hit a duration designator. // Note that we always expect at least the duration designator (P), but for loop safety we break if // the first character in the specification is reached too. $microseconds = ''; while ($position > 0) { $char = $specification[--$position]; if (!is_numeric($char)) { break; } $microseconds = $char . $microseconds; } // Remove the microsecond designator from the specification. $specification = substr($specification, 0, -1 - strlen($microseconds)); } // If the specification is just the duration designator it means that only microseconds were specified. // In that case we create an empty interval for convenience. if ('P' === $specification || 'PT' === $specification) { $specification = 'P0Y'; } return new static(new \DateInterval($specification), (int)$microseconds); }
[ "public", "static", "function", "fromSpecification", "(", "string", "$", "specification", ")", ":", "self", "{", "$", "microseconds", "=", "0", ";", "// Parse the microsecond component.", "if", "(", "false", "!==", "(", "$", "position", "=", "stripos", "(", "$...
Creates a new interval from a specification string. The specification follows ISO8601 with the exception that microseconds are supported via the U designator. @see https://en.wikipedia.org/wiki/ISO_8601#Durations @param string $specification @return self
[ "Creates", "a", "new", "interval", "from", "a", "specification", "string", "." ]
9a39084119bbfae2cf6e22d794aa04dd79344ce0
https://github.com/krixon/datetime/blob/9a39084119bbfae2cf6e22d794aa04dd79344ce0/src/DateInterval.php#L62-L95
train
krixon/datetime
src/DateInterval.php
DateInterval.diff
public static function diff(DateTime $a, DateTime $b, bool $absolute = false) : self { $microseconds = $b->microsecond() - $a->microsecond(); if ($absolute) { $microseconds = abs($microseconds); } $diff = $a->toInternalDateTime()->diff($b->toInternalDateTime(), $absolute); return new static($diff, $microseconds); }
php
public static function diff(DateTime $a, DateTime $b, bool $absolute = false) : self { $microseconds = $b->microsecond() - $a->microsecond(); if ($absolute) { $microseconds = abs($microseconds); } $diff = $a->toInternalDateTime()->diff($b->toInternalDateTime(), $absolute); return new static($diff, $microseconds); }
[ "public", "static", "function", "diff", "(", "DateTime", "$", "a", ",", "DateTime", "$", "b", ",", "bool", "$", "absolute", "=", "false", ")", ":", "self", "{", "$", "microseconds", "=", "$", "b", "->", "microsecond", "(", ")", "-", "$", "a", "->",...
Returns an interval representing the difference between two dates. @param DateTime $a @param DateTime $b @param bool $absolute @return self
[ "Returns", "an", "interval", "representing", "the", "difference", "between", "two", "dates", "." ]
9a39084119bbfae2cf6e22d794aa04dd79344ce0
https://github.com/krixon/datetime/blob/9a39084119bbfae2cf6e22d794aa04dd79344ce0/src/DateInterval.php#L107-L118
train
krixon/datetime
src/DateInterval.php
DateInterval.fromComponents
public static function fromComponents( int $years = null, int $months = null, int $weeks = null, int $days = null, int $hours = null, int $minutes = null, int $seconds = null, int $microseconds = null ) : self { if (!($years || $months || $weeks || $days || $hours || $minutes || $seconds || $microseconds)) { throw new \InvalidArgumentException('At least one component is required.'); } $years = $years ?: 0; $months = $months ?: 0; $weeks = $weeks ?: 0; $days = $days ?: 0; $hours = $hours ?: 0; $minutes = $minutes ?: 0; $seconds = $seconds ?: 0; $microseconds = $microseconds ?: 0; $specification = 'P'; if ($years) { $specification .= $years . 'Y'; } if ($months) { $specification .= $months . 'M'; } if ($weeks) { $specification .= $weeks . 'W'; } if ($days) { $specification .= $days . 'D'; } if ($hours || $minutes || $seconds) { $specification .= 'T'; if ($hours) { $specification .= $hours . 'H'; } if ($minutes) { $specification .= $minutes . 'M'; } if ($seconds) { $specification .= $seconds . 'M'; } } return new static(new \DateInterval($specification), $microseconds); }
php
public static function fromComponents( int $years = null, int $months = null, int $weeks = null, int $days = null, int $hours = null, int $minutes = null, int $seconds = null, int $microseconds = null ) : self { if (!($years || $months || $weeks || $days || $hours || $minutes || $seconds || $microseconds)) { throw new \InvalidArgumentException('At least one component is required.'); } $years = $years ?: 0; $months = $months ?: 0; $weeks = $weeks ?: 0; $days = $days ?: 0; $hours = $hours ?: 0; $minutes = $minutes ?: 0; $seconds = $seconds ?: 0; $microseconds = $microseconds ?: 0; $specification = 'P'; if ($years) { $specification .= $years . 'Y'; } if ($months) { $specification .= $months . 'M'; } if ($weeks) { $specification .= $weeks . 'W'; } if ($days) { $specification .= $days . 'D'; } if ($hours || $minutes || $seconds) { $specification .= 'T'; if ($hours) { $specification .= $hours . 'H'; } if ($minutes) { $specification .= $minutes . 'M'; } if ($seconds) { $specification .= $seconds . 'M'; } } return new static(new \DateInterval($specification), $microseconds); }
[ "public", "static", "function", "fromComponents", "(", "int", "$", "years", "=", "null", ",", "int", "$", "months", "=", "null", ",", "int", "$", "weeks", "=", "null", ",", "int", "$", "days", "=", "null", ",", "int", "$", "hours", "=", "null", ","...
Note that if weeks and days are both specified, only days will be used and weeks will be ignored. @param int|null $years @param int|null $months @param int|null $weeks @param int|null $days @param int|null $hours @param int|null $minutes @param int|null $seconds @param int|null $microseconds @return self
[ "Note", "that", "if", "weeks", "and", "days", "are", "both", "specified", "only", "days", "will", "be", "used", "and", "weeks", "will", "be", "ignored", "." ]
9a39084119bbfae2cf6e22d794aa04dd79344ce0
https://github.com/krixon/datetime/blob/9a39084119bbfae2cf6e22d794aa04dd79344ce0/src/DateInterval.php#L135-L193
train
krixon/datetime
src/DateInterval.php
DateInterval.format
public function format(string $format) : string { // Replace microseconds first so they become literals. // Ignore any escaped microsecond identifiers. $format = preg_replace_callback( // Starting at the start of the string or the first non % character, // consume pairs of % characters (effectively consuming all escaped %s) // and finally match the string %u. '/((?:^|[^%])(?:%{2})*)(%u)/', function (array $matches) { return $matches[1] . $this->microseconds; }, $format ); $format = $this->wrapped->format($format); return $format; }
php
public function format(string $format) : string { // Replace microseconds first so they become literals. // Ignore any escaped microsecond identifiers. $format = preg_replace_callback( // Starting at the start of the string or the first non % character, // consume pairs of % characters (effectively consuming all escaped %s) // and finally match the string %u. '/((?:^|[^%])(?:%{2})*)(%u)/', function (array $matches) { return $matches[1] . $this->microseconds; }, $format ); $format = $this->wrapped->format($format); return $format; }
[ "public", "function", "format", "(", "string", "$", "format", ")", ":", "string", "{", "// Replace microseconds first so they become literals.", "// Ignore any escaped microsecond identifiers.", "$", "format", "=", "preg_replace_callback", "(", "// Starting at the start of the st...
In addition to the regular \DateInterval formats, this also supports %u for microseconds. @param string $format @return string
[ "In", "addition", "to", "the", "regular", "\\", "DateInterval", "formats", "this", "also", "supports", "%u", "for", "microseconds", "." ]
9a39084119bbfae2cf6e22d794aa04dd79344ce0
https://github.com/krixon/datetime/blob/9a39084119bbfae2cf6e22d794aa04dd79344ce0/src/DateInterval.php#L247-L265
train
krixon/datetime
src/DateInterval.php
DateInterval.totalMicroseconds
public function totalMicroseconds() : int { if (null === $this->totalMicroseconds) { $reference = DateTime::now(); $end = $reference->add($this); $this->totalMicroseconds = $end->timestampWithMicrosecond() - $reference->timestampWithMicrosecond(); } return $this->totalMicroseconds; }
php
public function totalMicroseconds() : int { if (null === $this->totalMicroseconds) { $reference = DateTime::now(); $end = $reference->add($this); $this->totalMicroseconds = $end->timestampWithMicrosecond() - $reference->timestampWithMicrosecond(); } return $this->totalMicroseconds; }
[ "public", "function", "totalMicroseconds", "(", ")", ":", "int", "{", "if", "(", "null", "===", "$", "this", "->", "totalMicroseconds", ")", "{", "$", "reference", "=", "DateTime", "::", "now", "(", ")", ";", "$", "end", "=", "$", "reference", "->", ...
The total number of microseconds represented by the interval. @return int
[ "The", "total", "number", "of", "microseconds", "represented", "by", "the", "interval", "." ]
9a39084119bbfae2cf6e22d794aa04dd79344ce0
https://github.com/krixon/datetime/blob/9a39084119bbfae2cf6e22d794aa04dd79344ce0/src/DateInterval.php#L308-L318
train
krixon/datetime
src/DateInterval.php
DateInterval.clone
private static function clone(\DateInterval $interval) { $specification = $interval->format('P%yY%mM%dDT%hH%iM%sS'); $clone = new \DateInterval($specification); $clone->days = $interval->days; $clone->invert = $interval->invert; return $clone; }
php
private static function clone(\DateInterval $interval) { $specification = $interval->format('P%yY%mM%dDT%hH%iM%sS'); $clone = new \DateInterval($specification); $clone->days = $interval->days; $clone->invert = $interval->invert; return $clone; }
[ "private", "static", "function", "clone", "(", "\\", "DateInterval", "$", "interval", ")", "{", "$", "specification", "=", "$", "interval", "->", "format", "(", "'P%yY%mM%dDT%hH%iM%sS'", ")", ";", "$", "clone", "=", "new", "\\", "DateInterval", "(", "$", "...
Clone does not work for DateInterval object for some reason, it leads to an error. "The DateInterval object has not been correctly initialized by its constructor" This method works around this by creating an equivalent instance manually. @param \DateInterval $interval @return \DateInterval
[ "Clone", "does", "not", "work", "for", "DateInterval", "object", "for", "some", "reason", "it", "leads", "to", "an", "error", "." ]
9a39084119bbfae2cf6e22d794aa04dd79344ce0
https://github.com/krixon/datetime/blob/9a39084119bbfae2cf6e22d794aa04dd79344ce0/src/DateInterval.php#L395-L405
train
mirko-pagliai/me-cms
src/Controller/PostsCategoriesController.php
PostsCategoriesController.view
public function view($slug = null) { //The category can be passed as query string, from a widget if ($this->request->getQuery('q')) { return $this->redirect([$this->request->getQuery('q')]); } $page = $this->request->getQuery('page', 1); //Sets the cache name $cache = sprintf('category_%s_limit_%s_page_%s', md5($slug), $this->paginate['limit'], $page); //Tries to get data from the cache list($posts, $paging) = array_values(Cache::readMany( [$cache, sprintf('%s_paging', $cache)], $this->PostsCategories->getCacheName() )); //If the data are not available from the cache if (empty($posts) || empty($paging)) { $query = $this->PostsCategories->Posts->find('active') ->find('forIndex') ->where([sprintf('%s.slug', $this->PostsCategories->getAlias()) => $slug]); is_true_or_fail(!$query->isEmpty(), I18N_NOT_FOUND, RecordNotFoundException::class); $posts = $this->paginate($query); //Writes on cache Cache::writeMany([ $cache => $posts, sprintf('%s_paging', $cache) => $this->request->getParam('paging'), ], $this->PostsCategories->getCacheName()); //Else, sets the paging parameter } else { $this->request = $this->request->withParam('paging', $paging); } $this->set('category', $posts->extract('category')->first()); $this->set(compact('posts')); }
php
public function view($slug = null) { //The category can be passed as query string, from a widget if ($this->request->getQuery('q')) { return $this->redirect([$this->request->getQuery('q')]); } $page = $this->request->getQuery('page', 1); //Sets the cache name $cache = sprintf('category_%s_limit_%s_page_%s', md5($slug), $this->paginate['limit'], $page); //Tries to get data from the cache list($posts, $paging) = array_values(Cache::readMany( [$cache, sprintf('%s_paging', $cache)], $this->PostsCategories->getCacheName() )); //If the data are not available from the cache if (empty($posts) || empty($paging)) { $query = $this->PostsCategories->Posts->find('active') ->find('forIndex') ->where([sprintf('%s.slug', $this->PostsCategories->getAlias()) => $slug]); is_true_or_fail(!$query->isEmpty(), I18N_NOT_FOUND, RecordNotFoundException::class); $posts = $this->paginate($query); //Writes on cache Cache::writeMany([ $cache => $posts, sprintf('%s_paging', $cache) => $this->request->getParam('paging'), ], $this->PostsCategories->getCacheName()); //Else, sets the paging parameter } else { $this->request = $this->request->withParam('paging', $paging); } $this->set('category', $posts->extract('category')->first()); $this->set(compact('posts')); }
[ "public", "function", "view", "(", "$", "slug", "=", "null", ")", "{", "//The category can be passed as query string, from a widget", "if", "(", "$", "this", "->", "request", "->", "getQuery", "(", "'q'", ")", ")", "{", "return", "$", "this", "->", "redirect",...
Lists posts for a category @param string $slug Category slug @return \Cake\Network\Response|null|void @throws RecordNotFoundException
[ "Lists", "posts", "for", "a", "category" ]
df668ad8e3ee221497c47578d474e487f24ce92a
https://github.com/mirko-pagliai/me-cms/blob/df668ad8e3ee221497c47578d474e487f24ce92a/src/Controller/PostsCategoriesController.php#L45-L85
train
mirko-pagliai/me-cms
src/Controller/Admin/LogsController.php
LogsController.getPath
protected function getPath($filename, $serialized) { if ($serialized) { $filename = pathinfo($filename, PATHINFO_FILENAME) . '_serialized.log'; } return LOGS . $filename; }
php
protected function getPath($filename, $serialized) { if ($serialized) { $filename = pathinfo($filename, PATHINFO_FILENAME) . '_serialized.log'; } return LOGS . $filename; }
[ "protected", "function", "getPath", "(", "$", "filename", ",", "$", "serialized", ")", "{", "if", "(", "$", "serialized", ")", "{", "$", "filename", "=", "pathinfo", "(", "$", "filename", ",", "PATHINFO_FILENAME", ")", ".", "'_serialized.log'", ";", "}", ...
Internal method to get the path for a log @param string $filename Filename @param bool $serialized `true` for a serialized log @return string
[ "Internal", "method", "to", "get", "the", "path", "for", "a", "log" ]
df668ad8e3ee221497c47578d474e487f24ce92a
https://github.com/mirko-pagliai/me-cms/blob/df668ad8e3ee221497c47578d474e487f24ce92a/src/Controller/Admin/LogsController.php#L31-L38
train
mirko-pagliai/me-cms
src/Controller/Admin/LogsController.php
LogsController.read
protected function read($filename, $serialized) { $log = $this->getPath($filename, $serialized); is_readable_or_fail($log); $log = file_get_contents($log); return $serialized ? @unserialize($log) : trim($log); }
php
protected function read($filename, $serialized) { $log = $this->getPath($filename, $serialized); is_readable_or_fail($log); $log = file_get_contents($log); return $serialized ? @unserialize($log) : trim($log); }
[ "protected", "function", "read", "(", "$", "filename", ",", "$", "serialized", ")", "{", "$", "log", "=", "$", "this", "->", "getPath", "(", "$", "filename", ",", "$", "serialized", ")", ";", "is_readable_or_fail", "(", "$", "log", ")", ";", "$", "lo...
Internal method to read a log content @param string $filename Filename @param bool $serialized `true` for a serialized log @return string|array Log as array for serialized logs, otherwise a string @uses getPath()
[ "Internal", "method", "to", "read", "a", "log", "content" ]
df668ad8e3ee221497c47578d474e487f24ce92a
https://github.com/mirko-pagliai/me-cms/blob/df668ad8e3ee221497c47578d474e487f24ce92a/src/Controller/Admin/LogsController.php#L47-L54
train
mirko-pagliai/me-cms
src/Controller/Admin/LogsController.php
LogsController.view
public function view($filename) { $serialized = false; if ($this->request->getQuery('as') === 'serialized') { $serialized = true; $this->viewBuilder()->setTemplate('view_as_serialized'); } $content = $this->read($filename, $serialized); $this->set(compact('content', 'filename')); }
php
public function view($filename) { $serialized = false; if ($this->request->getQuery('as') === 'serialized') { $serialized = true; $this->viewBuilder()->setTemplate('view_as_serialized'); } $content = $this->read($filename, $serialized); $this->set(compact('content', 'filename')); }
[ "public", "function", "view", "(", "$", "filename", ")", "{", "$", "serialized", "=", "false", ";", "if", "(", "$", "this", "->", "request", "->", "getQuery", "(", "'as'", ")", "===", "'serialized'", ")", "{", "$", "serialized", "=", "true", ";", "$"...
Views a log @param string $filename Filename @return void @uses read()
[ "Views", "a", "log" ]
df668ad8e3ee221497c47578d474e487f24ce92a
https://github.com/mirko-pagliai/me-cms/blob/df668ad8e3ee221497c47578d474e487f24ce92a/src/Controller/Admin/LogsController.php#L95-L107
train
mirko-pagliai/me-cms
src/Controller/Admin/LogsController.php
LogsController.download
public function download($filename) { return $this->response->withFile($this->getPath($filename, false), ['download' => true]); }
php
public function download($filename) { return $this->response->withFile($this->getPath($filename, false), ['download' => true]); }
[ "public", "function", "download", "(", "$", "filename", ")", "{", "return", "$", "this", "->", "response", "->", "withFile", "(", "$", "this", "->", "getPath", "(", "$", "filename", ",", "false", ")", ",", "[", "'download'", "=>", "true", "]", ")", "...
Downloads a log @param string $filename Log filename @return \Cake\Network\Response @uses getPath()
[ "Downloads", "a", "log" ]
df668ad8e3ee221497c47578d474e487f24ce92a
https://github.com/mirko-pagliai/me-cms/blob/df668ad8e3ee221497c47578d474e487f24ce92a/src/Controller/Admin/LogsController.php#L115-L118
train
mirko-pagliai/me-cms
src/Controller/Admin/LogsController.php
LogsController.delete
public function delete($filename) { $this->request->allowMethod(['post', 'delete']); $success = (new File($this->getPath($filename, false)))->delete(); $serialized = $this->getPath($filename, true); //Deletes the serialized log copy, if it exists if (file_exists($serialized)) { $successSerialized = (new File($serialized))->delete(); } if ($success && $successSerialized) { $this->Flash->success(I18N_OPERATION_OK); } else { $this->Flash->error(I18N_OPERATION_NOT_OK); } return $this->redirect(['action' => 'index']); }
php
public function delete($filename) { $this->request->allowMethod(['post', 'delete']); $success = (new File($this->getPath($filename, false)))->delete(); $serialized = $this->getPath($filename, true); //Deletes the serialized log copy, if it exists if (file_exists($serialized)) { $successSerialized = (new File($serialized))->delete(); } if ($success && $successSerialized) { $this->Flash->success(I18N_OPERATION_OK); } else { $this->Flash->error(I18N_OPERATION_NOT_OK); } return $this->redirect(['action' => 'index']); }
[ "public", "function", "delete", "(", "$", "filename", ")", "{", "$", "this", "->", "request", "->", "allowMethod", "(", "[", "'post'", ",", "'delete'", "]", ")", ";", "$", "success", "=", "(", "new", "File", "(", "$", "this", "->", "getPath", "(", ...
Deletes a log. If there's even a serialized log copy, it also deletes that. @param string $filename Filename @return \Cake\Network\Response|null @uses getPath()
[ "Deletes", "a", "log", ".", "If", "there", "s", "even", "a", "serialized", "log", "copy", "it", "also", "deletes", "that", "." ]
df668ad8e3ee221497c47578d474e487f24ce92a
https://github.com/mirko-pagliai/me-cms/blob/df668ad8e3ee221497c47578d474e487f24ce92a/src/Controller/Admin/LogsController.php#L127-L146
train
mirko-pagliai/me-cms
src/Controller/PhotosController.php
PhotosController.view
public function view($slug = null, $id = null) { //This allows backward compatibility for URLs like `/photo/11` if (empty($slug)) { $slug = $this->Photos->findById($id) ->contain([$this->Photos->Albums->getAlias() => ['fields' => ['slug']]]) ->extract('album.slug') ->first(); return $this->redirect(compact('id', 'slug'), 301); } $photo = $this->Photos->findActiveById($id) ->select(['id', 'album_id', 'filename', 'active', 'modified']) ->contain([$this->Photos->Albums->getAlias() => ['fields' => ['id', 'title', 'slug']]]) ->cache(sprintf('view_%s', md5($id)), $this->Photos->getCacheName()) ->firstOrFail(); $this->set(compact('photo')); }
php
public function view($slug = null, $id = null) { //This allows backward compatibility for URLs like `/photo/11` if (empty($slug)) { $slug = $this->Photos->findById($id) ->contain([$this->Photos->Albums->getAlias() => ['fields' => ['slug']]]) ->extract('album.slug') ->first(); return $this->redirect(compact('id', 'slug'), 301); } $photo = $this->Photos->findActiveById($id) ->select(['id', 'album_id', 'filename', 'active', 'modified']) ->contain([$this->Photos->Albums->getAlias() => ['fields' => ['id', 'title', 'slug']]]) ->cache(sprintf('view_%s', md5($id)), $this->Photos->getCacheName()) ->firstOrFail(); $this->set(compact('photo')); }
[ "public", "function", "view", "(", "$", "slug", "=", "null", ",", "$", "id", "=", "null", ")", "{", "//This allows backward compatibility for URLs like `/photo/11`", "if", "(", "empty", "(", "$", "slug", ")", ")", "{", "$", "slug", "=", "$", "this", "->", ...
Views a photo @param string $slug Album slug @param string $id Photo ID @return \Cake\Network\Response|null|void
[ "Views", "a", "photo" ]
df668ad8e3ee221497c47578d474e487f24ce92a
https://github.com/mirko-pagliai/me-cms/blob/df668ad8e3ee221497c47578d474e487f24ce92a/src/Controller/PhotosController.php#L29-L48
train
mirko-pagliai/me-cms
src/Controller/PhotosController.php
PhotosController.preview
public function preview($id = null) { $photo = $this->Photos->findPendingById($id) ->select(['id', 'album_id', 'filename']) ->contain([$this->Photos->Albums->getAlias() => ['fields' => ['id', 'title', 'slug']]]) ->firstOrFail(); $this->set(compact('photo')); $this->render('view'); }
php
public function preview($id = null) { $photo = $this->Photos->findPendingById($id) ->select(['id', 'album_id', 'filename']) ->contain([$this->Photos->Albums->getAlias() => ['fields' => ['id', 'title', 'slug']]]) ->firstOrFail(); $this->set(compact('photo')); $this->render('view'); }
[ "public", "function", "preview", "(", "$", "id", "=", "null", ")", "{", "$", "photo", "=", "$", "this", "->", "Photos", "->", "findPendingById", "(", "$", "id", ")", "->", "select", "(", "[", "'id'", ",", "'album_id'", ",", "'filename'", "]", ")", ...
Preview for photos. It uses the `view` template. @param string $id Photo ID @return \Cake\Network\Response|null|void
[ "Preview", "for", "photos", ".", "It", "uses", "the", "view", "template", "." ]
df668ad8e3ee221497c47578d474e487f24ce92a
https://github.com/mirko-pagliai/me-cms/blob/df668ad8e3ee221497c47578d474e487f24ce92a/src/Controller/PhotosController.php#L56-L65
train
merk/Dough
lib/Dough/Bank/MultiCurrencyBank.php
MultiCurrencyBank.checkCurrencies
protected function checkCurrencies($currencies) { foreach ((array) $currencies as $currency) { if (!$this->hasCurrency($currency)) { throw new InvalidCurrencyException(sprintf('"%s" is an unknown currency code.', $currency)); } } }
php
protected function checkCurrencies($currencies) { foreach ((array) $currencies as $currency) { if (!$this->hasCurrency($currency)) { throw new InvalidCurrencyException(sprintf('"%s" is an unknown currency code.', $currency)); } } }
[ "protected", "function", "checkCurrencies", "(", "$", "currencies", ")", "{", "foreach", "(", "(", "array", ")", "$", "currencies", "as", "$", "currency", ")", "{", "if", "(", "!", "$", "this", "->", "hasCurrency", "(", "$", "currency", ")", ")", "{", ...
Checks to see if the currencies supplied are known or unknown. @param array|string $currencies @throws \Dough\Exception\InvalidCurrencyException when currencies are unknown.
[ "Checks", "to", "see", "if", "the", "currencies", "supplied", "are", "known", "or", "unknown", "." ]
af36775564fbaf46a8018acc4f1fd993530c1a96
https://github.com/merk/Dough/blob/af36775564fbaf46a8018acc4f1fd993530c1a96/lib/Dough/Bank/MultiCurrencyBank.php#L102-L109
train
merk/Dough
lib/Dough/Bank/MultiCurrencyBank.php
MultiCurrencyBank.getRate
public function getRate($fromCurrency, $toCurrency = null) { if (null === $toCurrency) { $toCurrency = $this->getBaseCurrency(); } $this->checkCurrencies(array($fromCurrency, $toCurrency)); return $this->exchanger->getRate($fromCurrency, $toCurrency); }
php
public function getRate($fromCurrency, $toCurrency = null) { if (null === $toCurrency) { $toCurrency = $this->getBaseCurrency(); } $this->checkCurrencies(array($fromCurrency, $toCurrency)); return $this->exchanger->getRate($fromCurrency, $toCurrency); }
[ "public", "function", "getRate", "(", "$", "fromCurrency", ",", "$", "toCurrency", "=", "null", ")", "{", "if", "(", "null", "===", "$", "toCurrency", ")", "{", "$", "toCurrency", "=", "$", "this", "->", "getBaseCurrency", "(", ")", ";", "}", "$", "t...
Returns the current exchange rate between 2 currencies. @param string $fromCurrency @param string|null $toCurrency @return float @throws \Dough\Exception\InvalidCurrencyException when a supplied currency is unknown. @throws \InvalidArgumentException when a currency does not exist or when the supplied currencies do not have an exchange rate set.
[ "Returns", "the", "current", "exchange", "rate", "between", "2", "currencies", "." ]
af36775564fbaf46a8018acc4f1fd993530c1a96
https://github.com/merk/Dough/blob/af36775564fbaf46a8018acc4f1fd993530c1a96/lib/Dough/Bank/MultiCurrencyBank.php#L162-L171
train
merk/Dough
lib/Dough/Bank/MultiCurrencyBank.php
MultiCurrencyBank.reduce
public function reduce(MoneyInterface $source, $toCurrency = null) { if (null === $toCurrency) { $toCurrency = $this->getBaseCurrency(); } $this->checkCurrencies($toCurrency); return $source->reduce($this, $toCurrency); }
php
public function reduce(MoneyInterface $source, $toCurrency = null) { if (null === $toCurrency) { $toCurrency = $this->getBaseCurrency(); } $this->checkCurrencies($toCurrency); return $source->reduce($this, $toCurrency); }
[ "public", "function", "reduce", "(", "MoneyInterface", "$", "source", ",", "$", "toCurrency", "=", "null", ")", "{", "if", "(", "null", "===", "$", "toCurrency", ")", "{", "$", "toCurrency", "=", "$", "this", "->", "getBaseCurrency", "(", ")", ";", "}"...
Reduces the supplied monetary object into a single Money object of the supplied currency. @param \Dough\Money\MoneyInterface $source @param string|null $toCurrency @return Money @throws \Dough\Exception\InvalidCurrencyException when a supplied currency is unknown.
[ "Reduces", "the", "supplied", "monetary", "object", "into", "a", "single", "Money", "object", "of", "the", "supplied", "currency", "." ]
af36775564fbaf46a8018acc4f1fd993530c1a96
https://github.com/merk/Dough/blob/af36775564fbaf46a8018acc4f1fd993530c1a96/lib/Dough/Bank/MultiCurrencyBank.php#L185-L194
train
merk/Dough
lib/Dough/Bank/MultiCurrencyBank.php
MultiCurrencyBank.createMoney
public function createMoney($amount, $currency = null) { if (null === $currency) { $currency = $this->getBaseCurrency(); } $this->checkCurrencies($currency); $class = $this->moneyClass; return new $class($amount, $currency); }
php
public function createMoney($amount, $currency = null) { if (null === $currency) { $currency = $this->getBaseCurrency(); } $this->checkCurrencies($currency); $class = $this->moneyClass; return new $class($amount, $currency); }
[ "public", "function", "createMoney", "(", "$", "amount", ",", "$", "currency", "=", "null", ")", "{", "if", "(", "null", "===", "$", "currency", ")", "{", "$", "currency", "=", "$", "this", "->", "getBaseCurrency", "(", ")", ";", "}", "$", "this", ...
Creates a new money instance. If currency is not supplied the base currency for this bank is used. @param float|int $amount @param string|null $currency @return \Dough\Money\MultiCurrencyMoney @throws \Dough\Exception\InvalidCurrencyException when a supplied currency is unknown.
[ "Creates", "a", "new", "money", "instance", ".", "If", "currency", "is", "not", "supplied", "the", "base", "currency", "for", "this", "bank", "is", "used", "." ]
af36775564fbaf46a8018acc4f1fd993530c1a96
https://github.com/merk/Dough/blob/af36775564fbaf46a8018acc4f1fd993530c1a96/lib/Dough/Bank/MultiCurrencyBank.php#L208-L218
train
nails/module-auth
src/Model/Auth.php
Auth.verifyCredentials
public function verifyCredentials($sIdentifier, $sPassword) { // Look up the user, how we do so depends on the login mode that the app is using $oUserModel = Factory::model('User', 'nails/module-auth'); $oPasswordModel = Factory::model('UserPassword', 'nails/module-auth'); $oUser = $oUserModel->getByIdentifier($sIdentifier); return !empty($oUser) ? $oPasswordModel->isCorrect($oUser->id, $sPassword) : false; }
php
public function verifyCredentials($sIdentifier, $sPassword) { // Look up the user, how we do so depends on the login mode that the app is using $oUserModel = Factory::model('User', 'nails/module-auth'); $oPasswordModel = Factory::model('UserPassword', 'nails/module-auth'); $oUser = $oUserModel->getByIdentifier($sIdentifier); return !empty($oUser) ? $oPasswordModel->isCorrect($oUser->id, $sPassword) : false; }
[ "public", "function", "verifyCredentials", "(", "$", "sIdentifier", ",", "$", "sPassword", ")", "{", "// Look up the user, how we do so depends on the login mode that the app is using", "$", "oUserModel", "=", "Factory", "::", "model", "(", "'User'", ",", "'nails/module-au...
Verifies a user's login credentials @param string $sIdentifier The identifier to use for the lookup @param string $sPassword The user's password @return boolean
[ "Verifies", "a", "user", "s", "login", "credentials" ]
f9b0b554c1e06399fa8042dd94c5acf86bac5548
https://github.com/nails/module-auth/blob/f9b0b554c1e06399fa8042dd94c5acf86bac5548/src/Model/Auth.php#L211-L219
train