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
asika32764/joomla-framework-console
Command/AbstractCommand.php
AbstractCommand.setOptions
public function setOptions($options) { $options = is_array($options) ? $options : array($options); foreach ($options as $option) { $this->addOption($option); } return $this; }
php
public function setOptions($options) { $options = is_array($options) ? $options : array($options); foreach ($options as $option) { $this->addOption($option); } return $this; }
[ "public", "function", "setOptions", "(", "$", "options", ")", "{", "$", "options", "=", "is_array", "(", "$", "options", ")", "?", "$", "options", ":", "array", "(", "$", "options", ")", ";", "foreach", "(", "$", "options", "as", "$", "option", ")", ...
Batch add options to command. @param mixed $options An options array. @return AbstractCommand Return this object to support chaining. @since 1.0
[ "Batch", "add", "options", "to", "command", "." ]
fe28cf9e1c694049e015121e2bd041268e814249
https://github.com/asika32764/joomla-framework-console/blob/fe28cf9e1c694049e015121e2bd041268e814249/Command/AbstractCommand.php#L682-L692
train
asika32764/joomla-framework-console
Command/AbstractCommand.php
AbstractCommand.renderAlternatives
public function renderAlternatives($wrongName, $exception) { /** @var $exception \InvalidArgumentException */ $message = $exception->getMessage(); $autoComplete = ''; $alternatives = array(); // Autocomplete foreach ($this->children as $command) { /** @var $command Command */ $commandName = $command->getName(); /* * Here we use "Levenshtein distance" to compare wrong name with every command names. * * If the difference number less than 1/3 of wrong name which user typed, means this is a similar name, * we can notice user to choose these similar names. * * And if the string of wrong name can be found in a command name, we also notice user to choose it. */ if (levenshtein($wrongName, $commandName) <= (strlen($wrongName) / 3) || strpos($commandName, $wrongName) !== false) { $alternatives[] = " " . $commandName; } } if (count($alternatives)) { $autoComplete = "Did you mean one of these?\n"; $autoComplete .= implode($alternatives); } $this->out(''); $this->err("<error>{$message}</error>"); $this->out(''); $this->err($autoComplete); }
php
public function renderAlternatives($wrongName, $exception) { /** @var $exception \InvalidArgumentException */ $message = $exception->getMessage(); $autoComplete = ''; $alternatives = array(); // Autocomplete foreach ($this->children as $command) { /** @var $command Command */ $commandName = $command->getName(); /* * Here we use "Levenshtein distance" to compare wrong name with every command names. * * If the difference number less than 1/3 of wrong name which user typed, means this is a similar name, * we can notice user to choose these similar names. * * And if the string of wrong name can be found in a command name, we also notice user to choose it. */ if (levenshtein($wrongName, $commandName) <= (strlen($wrongName) / 3) || strpos($commandName, $wrongName) !== false) { $alternatives[] = " " . $commandName; } } if (count($alternatives)) { $autoComplete = "Did you mean one of these?\n"; $autoComplete .= implode($alternatives); } $this->out(''); $this->err("<error>{$message}</error>"); $this->out(''); $this->err($autoComplete); }
[ "public", "function", "renderAlternatives", "(", "$", "wrongName", ",", "$", "exception", ")", "{", "/** @var $exception \\InvalidArgumentException */", "$", "message", "=", "$", "exception", "->", "getMessage", "(", ")", ";", "$", "autoComplete", "=", "''", ";", ...
Render auto complete alternatives. @param string $wrongName The wrong command name to auto completed. @param CommandNotFoundException $exception The exception of wrong argument. @return void @since 1.0
[ "Render", "auto", "complete", "alternatives", "." ]
fe28cf9e1c694049e015121e2bd041268e814249
https://github.com/asika32764/joomla-framework-console/blob/fe28cf9e1c694049e015121e2bd041268e814249/Command/AbstractCommand.php#L897-L934
train
battis/appmetadata
src/AppMetadata.php
AppMetadata.offsetUnset
public function offsetUnset($key) { $_key = $this->sql->real_escape_string($key); if (!$this->sql->query("DELETE FROM `{$this->table}` WHERE `app` = '{$this->app}' AND `key` = '$_key'")) { throw new AppMetadata_Exception( "Unable to delete app metadata (`$_key`). {$this->sql->error}", AppMetadata_Exception::DELETE_FAIL ); } $result = parent::offsetUnset($key); $this->updateDerivedValues($key); return $result; }
php
public function offsetUnset($key) { $_key = $this->sql->real_escape_string($key); if (!$this->sql->query("DELETE FROM `{$this->table}` WHERE `app` = '{$this->app}' AND `key` = '$_key'")) { throw new AppMetadata_Exception( "Unable to delete app metadata (`$_key`). {$this->sql->error}", AppMetadata_Exception::DELETE_FAIL ); } $result = parent::offsetUnset($key); $this->updateDerivedValues($key); return $result; }
[ "public", "function", "offsetUnset", "(", "$", "key", ")", "{", "$", "_key", "=", "$", "this", "->", "sql", "->", "real_escape_string", "(", "$", "key", ")", ";", "if", "(", "!", "$", "this", "->", "sql", "->", "query", "(", "\"DELETE FROM `{$this->tab...
Transparently expunge the persistent app_metadata store when the data is unset @param int|string $key Array key whose value will be unset() @return void (unless ArrayObject::offsetUnset() returns a value... then this wil too!) @throws AppMetadata_Exception DELETE_FAIL if the deletion fails
[ "Transparently", "expunge", "the", "persistent", "app_metadata", "store", "when", "the", "data", "is", "unset" ]
16a0d2735a9bc2824e5a5a90d34717262a27b5cd
https://github.com/battis/appmetadata/blob/16a0d2735a9bc2824e5a5a90d34717262a27b5cd/src/AppMetadata.php#L126-L140
train
battis/appmetadata
src/AppMetadata.php
AppMetadata.buildDatabase
public function buildDatabase() { if ($this->sql) { if ($this->sql->query(" CREATE TABLE IF NOT EXISTS `{$this->table}` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `key` varchar(255) NOT NULL, `value` text, `validate` text, `timestamp` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `app` varchar(255) NOT NULL DEFAULT '', PRIMARY KEY (`id`) ); ")) { $this->initialized = true; /* Upgrade pre-v1.2 app_metadata tables to include independent IDs */ $this->sql->query(" ALTER TABLE `{$this->table}` DROP PRIMARY KEY, ADD `id` INT(11) UNSIGNED PRIMARY KEY AUTO_INCREMENT FIRST; "); } } return $this->initialized; }
php
public function buildDatabase() { if ($this->sql) { if ($this->sql->query(" CREATE TABLE IF NOT EXISTS `{$this->table}` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `key` varchar(255) NOT NULL, `value` text, `validate` text, `timestamp` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `app` varchar(255) NOT NULL DEFAULT '', PRIMARY KEY (`id`) ); ")) { $this->initialized = true; /* Upgrade pre-v1.2 app_metadata tables to include independent IDs */ $this->sql->query(" ALTER TABLE `{$this->table}` DROP PRIMARY KEY, ADD `id` INT(11) UNSIGNED PRIMARY KEY AUTO_INCREMENT FIRST; "); } } return $this->initialized; }
[ "public", "function", "buildDatabase", "(", ")", "{", "if", "(", "$", "this", "->", "sql", ")", "{", "if", "(", "$", "this", "->", "sql", "->", "query", "(", "\"\n\t\t\t\tCREATE TABLE IF NOT EXISTS `{$this->table}` (\n\t\t\t\t\t`id` int(11) unsigned NOT NULL AUTO_INCREM...
Create the supporting database table @return boolean TRUE iff the database tables were created, FALSE if some tables already existed in database (and were, therefore, not created and not over-written) @throws AppMetadata_Exception INVALID_MYSQLI_OBJECT if no valid mysqli object is provided to access the database @throws AppMetadata_Exception MISSING_SCHEMA if the schema file cannot be found @throws AppMetadata_Exception CREATE_TABLE_FAIL or PREPARE_DATABASE_FAIL if the schema tables cannot be loaded
[ "Create", "the", "supporting", "database", "table" ]
16a0d2735a9bc2824e5a5a90d34717262a27b5cd
https://github.com/battis/appmetadata/blob/16a0d2735a9bc2824e5a5a90d34717262a27b5cd/src/AppMetadata.php#L151-L175
train
battis/appmetadata
src/AppMetadata.php
AppMetadata.updateDerivedValues
private function updateDerivedValues($key = null, $value = null) { /* * TODO * I darkly suspect that there is a possibility that you could create a loop * of derived references that would be irresolvable and not currently detected * e.g. A => '@B', B=>'@C', C=>'@A'. Perhaps the best approach would be to * limit the depth of the derivation search? */ $derived = array(); /* determine breadth of derived fields affected */ $derivedPattern = '%@_%'; if (!empty($key)) { $_key = $this->sql->real_escape_string($key); $derivedPattern = "%@$_key%"; if (!empty($value) && is_string($value)) { $derived[$key] = $value; } } /* build a list of affected key => value pairs */ if ($result = $this->sql->query(" SELECT * FROM `{$this->table}` WHERE `value` LIKE '$derivedPattern' ")) { while($row = $result->fetch_assoc()) { $value = unserialize($row['value']); if (is_string($value)) { $derived[$row['key']] = $value; } } } /* generate derived fields based on prior fields */ while (count($derived) > 0) { $next = array(); foreach ($derived as $key => $value) { /* look for @keys in the value */ preg_match_all('/@(\w+)/', $value, $sources, PREG_SET_ORDER); $dirty = false; foreach($sources as $source) { if ($this->offsetExists($source[1]) && is_string($this->offsetGet($source[1]))) { $value = preg_replace("/{$source[0]}/", $this->offsetGet($source[1]), $value); $dirty = true; } } /* ...and queue up again to check */ if ($dirty) { $next[$key] = $value; } else { $this->_offsetSet($key, $value, false); } } /* use new queue */ $derived = $next; } }
php
private function updateDerivedValues($key = null, $value = null) { /* * TODO * I darkly suspect that there is a possibility that you could create a loop * of derived references that would be irresolvable and not currently detected * e.g. A => '@B', B=>'@C', C=>'@A'. Perhaps the best approach would be to * limit the depth of the derivation search? */ $derived = array(); /* determine breadth of derived fields affected */ $derivedPattern = '%@_%'; if (!empty($key)) { $_key = $this->sql->real_escape_string($key); $derivedPattern = "%@$_key%"; if (!empty($value) && is_string($value)) { $derived[$key] = $value; } } /* build a list of affected key => value pairs */ if ($result = $this->sql->query(" SELECT * FROM `{$this->table}` WHERE `value` LIKE '$derivedPattern' ")) { while($row = $result->fetch_assoc()) { $value = unserialize($row['value']); if (is_string($value)) { $derived[$row['key']] = $value; } } } /* generate derived fields based on prior fields */ while (count($derived) > 0) { $next = array(); foreach ($derived as $key => $value) { /* look for @keys in the value */ preg_match_all('/@(\w+)/', $value, $sources, PREG_SET_ORDER); $dirty = false; foreach($sources as $source) { if ($this->offsetExists($source[1]) && is_string($this->offsetGet($source[1]))) { $value = preg_replace("/{$source[0]}/", $this->offsetGet($source[1]), $value); $dirty = true; } } /* ...and queue up again to check */ if ($dirty) { $next[$key] = $value; } else { $this->_offsetSet($key, $value, false); } } /* use new queue */ $derived = $next; } }
[ "private", "function", "updateDerivedValues", "(", "$", "key", "=", "null", ",", "$", "value", "=", "null", ")", "{", "/* \n\t\t * TODO\n\t\t * I darkly suspect that there is a possibility that you could create a loop\n\t\t * of derived references that would be irresolvable and not cur...
Calculate the derived value for a particular offset For example... ```PHP $metadata['A'] = 'foo'; $metadata['B'] = '@A/bar'; echo $metadata['B']; // 'foo/bar'; $metadata['A'] = 'rutabega'; echo $metadata['B']; // 'rutabega/bar' ``` @param string $key (Optional) Limit the updates to values derived from `$key` @param string $value (Optiona) The value that is stored at `$key` which may itself need to be derived further @return void
[ "Calculate", "the", "derived", "value", "for", "a", "particular", "offset" ]
16a0d2735a9bc2824e5a5a90d34717262a27b5cd
https://github.com/battis/appmetadata/blob/16a0d2735a9bc2824e5a5a90d34717262a27b5cd/src/AppMetadata.php#L217-L282
train
battis/appmetadata
src/AppMetadata.php
AppMetadata.derivedValues
public function derivedValues($s) { preg_match_all('/@(\w+)/', $s, $possibilities, PREG_SET_ORDER); foreach ($possibilities as $possibility) { if ($this->offsetExists($possibility[1]) && is_string($this->offsetGet($possibility[1]))) { $s = str_replace($possibility[0], $this->offsetGet($possibility[1]), $s); } } return $s; }
php
public function derivedValues($s) { preg_match_all('/@(\w+)/', $s, $possibilities, PREG_SET_ORDER); foreach ($possibilities as $possibility) { if ($this->offsetExists($possibility[1]) && is_string($this->offsetGet($possibility[1]))) { $s = str_replace($possibility[0], $this->offsetGet($possibility[1]), $s); } } return $s; }
[ "public", "function", "derivedValues", "(", "$", "s", ")", "{", "preg_match_all", "(", "'/@(\\w+)/'", ",", "$", "s", ",", "$", "possibilities", ",", "PREG_SET_ORDER", ")", ";", "foreach", "(", "$", "possibilities", "as", "$", "possibility", ")", "{", "if",...
Replace derived values in an abitrary string using AppMetadata @param string $s @return string
[ "Replace", "derived", "values", "in", "an", "abitrary", "string", "using", "AppMetadata" ]
16a0d2735a9bc2824e5a5a90d34717262a27b5cd
https://github.com/battis/appmetadata/blob/16a0d2735a9bc2824e5a5a90d34717262a27b5cd/src/AppMetadata.php#L291-L299
train
restrose/water
src/Shop.php
Shop.getGoodsSN
public function getGoodsSN() { $step = 5000; $start = 100; $max = Goods::max('sn'); $max = count($max) && $max > $start ? $max : $start; $sn = $max+1; $sn_str = strval($sn); if(str_contains($sn_str, '4')) { $sn_str = str_replace('4', '5', $sn_str); } $sn = intval($sn_str); $in_offer = Offer::where('sn', $sn)->first(); $max_offer = Offer::max('sn'); if(count($in_offer)) { $sn = $step * ceil($max_offer / $step)+ $step; } return $sn; }
php
public function getGoodsSN() { $step = 5000; $start = 100; $max = Goods::max('sn'); $max = count($max) && $max > $start ? $max : $start; $sn = $max+1; $sn_str = strval($sn); if(str_contains($sn_str, '4')) { $sn_str = str_replace('4', '5', $sn_str); } $sn = intval($sn_str); $in_offer = Offer::where('sn', $sn)->first(); $max_offer = Offer::max('sn'); if(count($in_offer)) { $sn = $step * ceil($max_offer / $step)+ $step; } return $sn; }
[ "public", "function", "getGoodsSN", "(", ")", "{", "$", "step", "=", "5000", ";", "$", "start", "=", "100", ";", "$", "max", "=", "Goods", "::", "max", "(", "'sn'", ")", ";", "$", "max", "=", "count", "(", "$", "max", ")", "&&", "$", "max", "...
get shop sn
[ "get", "shop", "sn" ]
b1ca5e0b77ed73a98b532a5589d6c14012b2bef1
https://github.com/restrose/water/blob/b1ca5e0b77ed73a98b532a5589d6c14012b2bef1/src/Shop.php#L21-L41
train
restrose/water
src/Shop.php
Shop.getOfferSN
public function getOfferSN() { $start = 5000; $step = 5000; $max = Offer::max('sn'); $max = count($max) && $max > $start ? $max : $start; $sn = $max+1; $sn_str = strval($sn); if(str_contains($sn_str, '4')) { $sn_str = str_replace('4', '5', $sn_str); } $sn = intval($sn_str); $in_goods = Goods::where('sn', $sn)->first(); $max_goods = Goods::max('sn'); if(count($in_goods)) { $sn = $step * ceil($max_goods / $step)+ $step; } return $sn; }
php
public function getOfferSN() { $start = 5000; $step = 5000; $max = Offer::max('sn'); $max = count($max) && $max > $start ? $max : $start; $sn = $max+1; $sn_str = strval($sn); if(str_contains($sn_str, '4')) { $sn_str = str_replace('4', '5', $sn_str); } $sn = intval($sn_str); $in_goods = Goods::where('sn', $sn)->first(); $max_goods = Goods::max('sn'); if(count($in_goods)) { $sn = $step * ceil($max_goods / $step)+ $step; } return $sn; }
[ "public", "function", "getOfferSN", "(", ")", "{", "$", "start", "=", "5000", ";", "$", "step", "=", "5000", ";", "$", "max", "=", "Offer", "::", "max", "(", "'sn'", ")", ";", "$", "max", "=", "count", "(", "$", "max", ")", "&&", "$", "max", ...
get offer sn
[ "get", "offer", "sn" ]
b1ca5e0b77ed73a98b532a5589d6c14012b2bef1
https://github.com/restrose/water/blob/b1ca5e0b77ed73a98b532a5589d6c14012b2bef1/src/Shop.php#L47-L67
train
php-rest-server/core
src/Core/General/Cyphers/OpenSSLCypher.php
OpenSSLCypher.encode
public function encode($data) { return openssl_encrypt($data, $this->method, $this->key, 0, $this->iv); }
php
public function encode($data) { return openssl_encrypt($data, $this->method, $this->key, 0, $this->iv); }
[ "public", "function", "encode", "(", "$", "data", ")", "{", "return", "openssl_encrypt", "(", "$", "data", ",", "$", "this", "->", "method", ",", "$", "this", "->", "key", ",", "0", ",", "$", "this", "->", "iv", ")", ";", "}" ]
Encode data by openssl_encrypt @param string $data @return string
[ "Encode", "data", "by", "openssl_encrypt" ]
4d1ee0d4b6bd7d170cf1ec924a8b743b5d486888
https://github.com/php-rest-server/core/blob/4d1ee0d4b6bd7d170cf1ec924a8b743b5d486888/src/Core/General/Cyphers/OpenSSLCypher.php#L58-L61
train
php-rest-server/core
src/Core/General/Cyphers/OpenSSLCypher.php
OpenSSLCypher.decode
public function decode($data) { return openssl_decrypt($data, $this->method, $this->key, 0, $this->iv); }
php
public function decode($data) { return openssl_decrypt($data, $this->method, $this->key, 0, $this->iv); }
[ "public", "function", "decode", "(", "$", "data", ")", "{", "return", "openssl_decrypt", "(", "$", "data", ",", "$", "this", "->", "method", ",", "$", "this", "->", "key", ",", "0", ",", "$", "this", "->", "iv", ")", ";", "}" ]
Decode data by openssl_decrypt @param string $data @return string
[ "Decode", "data", "by", "openssl_decrypt" ]
4d1ee0d4b6bd7d170cf1ec924a8b743b5d486888
https://github.com/php-rest-server/core/blob/4d1ee0d4b6bd7d170cf1ec924a8b743b5d486888/src/Core/General/Cyphers/OpenSSLCypher.php#L70-L73
train
gliverphp/database
src/DbImplement.php
DbImplement.initialize
public function initialize() { //throw exception if no database type has been set if( ! $this->type ) { //Throw exception throw new DbException("Invalid database type provided"); } //check the type of database provided returning instance //set the parameter to check in switch clause switch ($this->type ) { case 'mysql': return new MySQL($this->options); break; default: throw new DbException("Valid database type provided"); break; } }
php
public function initialize() { //throw exception if no database type has been set if( ! $this->type ) { //Throw exception throw new DbException("Invalid database type provided"); } //check the type of database provided returning instance //set the parameter to check in switch clause switch ($this->type ) { case 'mysql': return new MySQL($this->options); break; default: throw new DbException("Valid database type provided"); break; } }
[ "public", "function", "initialize", "(", ")", "{", "//throw exception if no database type has been set", "if", "(", "!", "$", "this", "->", "type", ")", "{", "//Throw exception", "throw", "new", "DbException", "(", "\"Invalid database type provided\"", ")", ";", "}", ...
This method initializes a database connection @param null @return object Instance of this database connection @throws DbException If the database type provided is not defined for this system
[ "This", "method", "initializes", "a", "database", "connection" ]
b998bd3d24cb2f269b9bd54438c7df8751377ba9
https://github.com/gliverphp/database/blob/b998bd3d24cb2f269b9bd54438c7df8751377ba9/src/DbImplement.php#L39-L67
train
docit/core
src/Parsers/ParsedownExtra.php
ParsedownExtra.blockFencedCode
protected function blockFencedCode($line) { $regex = '/^([' . $line[ 'text' ][ 0 ] . ']{3,})[ ]*([\w-]+)?[ ]*$/'; if (preg_match($regex, $line[ 'text' ], $matches)) { $element = [ 'name' => 'code', 'text' => '', ]; if (isset($matches[ 2 ])) { $class = $this->getConfig('fenced_code_lang_class', 'prettyprint lang-{LANG}'); $class = str_replace('{LANG}', $matches[2], $class); //'prettyprint lang-' . $matches[ 2 ]; $element[ 'attributes' ] = [ 'class' => $class ]; } $block = [ 'char' => $line[ 'text' ][ 0 ], 'element' => [ 'name' => 'pre', 'handler' => 'element', 'text' => $element, ], ]; return $block; } }
php
protected function blockFencedCode($line) { $regex = '/^([' . $line[ 'text' ][ 0 ] . ']{3,})[ ]*([\w-]+)?[ ]*$/'; if (preg_match($regex, $line[ 'text' ], $matches)) { $element = [ 'name' => 'code', 'text' => '', ]; if (isset($matches[ 2 ])) { $class = $this->getConfig('fenced_code_lang_class', 'prettyprint lang-{LANG}'); $class = str_replace('{LANG}', $matches[2], $class); //'prettyprint lang-' . $matches[ 2 ]; $element[ 'attributes' ] = [ 'class' => $class ]; } $block = [ 'char' => $line[ 'text' ][ 0 ], 'element' => [ 'name' => 'pre', 'handler' => 'element', 'text' => $element, ], ]; return $block; } }
[ "protected", "function", "blockFencedCode", "(", "$", "line", ")", "{", "$", "regex", "=", "'/^(['", ".", "$", "line", "[", "'text'", "]", "[", "0", "]", ".", "']{3,})[ ]*([\\w-]+)?[ ]*$/'", ";", "if", "(", "preg_match", "(", "$", "regex", ",", "$", "l...
Parse fenced code blocks. @param array $line @return array
[ "Parse", "fenced", "code", "blocks", "." ]
448e1cdca18a8ffb6c08430cad8d22162171ac35
https://github.com/docit/core/blob/448e1cdca18a8ffb6c08430cad8d22162171ac35/src/Parsers/ParsedownExtra.php#L58-L86
train
docit/core
src/Parsers/ParsedownExtra.php
ParsedownExtra.blockTable
protected function blockTable($line, array $block = null) { if (! isset($block) or isset($block[ 'type' ]) or isset($block[ 'interrupted' ])) { return; } if (strpos($block[ 'element' ][ 'text' ], '|') !== false and chop($line[ 'text' ], ' -:|') === '') { $alignments = array(); $divider = $line[ 'text' ]; $divider = trim($divider); $divider = trim($divider, '|'); $dividerCells = explode('|', $divider); foreach ($dividerCells as $dividerCell) { $dividerCell = trim($dividerCell); if ($dividerCell === '') { continue; } $alignment = null; if ($dividerCell[ 0 ] === ':') { $alignment = 'left'; } if (substr($dividerCell, -1) === ':') { $alignment = $alignment === 'left' ? 'center' : 'right'; } $alignments[] = $alignment; } $headerElements = array(); $header = $block[ 'element' ][ 'text' ]; $header = trim($header); $header = trim($header, '|'); $headerCells = explode('|', $header); foreach ($headerCells as $index => $headerCell) { $headerCell = trim($headerCell); $headerElement = [ 'name' => 'th', 'text' => $headerCell, 'handler' => 'line', ]; if (isset($alignments[ $index ])) { $alignment = $alignments[ $index ]; $headerElement[ 'attributes' ] = [ 'style' => 'text-align: ' . $alignment . ';', ]; } $headerElements[] = $headerElement; } $block = [ 'alignments' => $alignments, 'identified' => true, 'element' => [ 'name' => 'table', 'handler' => 'elements', 'attributes' => [ 'class' => 'table table-striped table-bordered' ], ], ]; $block[ 'element' ][ 'text' ][] = [ 'name' => 'thead', 'handler' => 'elements', ]; $block[ 'element' ][ 'text' ][] = [ 'name' => 'tbody', 'handler' => 'elements', 'text' => array(), ]; $block[ 'element' ][ 'text' ][ 0 ][ 'text' ][] = [ 'name' => 'tr', 'handler' => 'elements', 'text' => $headerElements, ]; return $block; } }
php
protected function blockTable($line, array $block = null) { if (! isset($block) or isset($block[ 'type' ]) or isset($block[ 'interrupted' ])) { return; } if (strpos($block[ 'element' ][ 'text' ], '|') !== false and chop($line[ 'text' ], ' -:|') === '') { $alignments = array(); $divider = $line[ 'text' ]; $divider = trim($divider); $divider = trim($divider, '|'); $dividerCells = explode('|', $divider); foreach ($dividerCells as $dividerCell) { $dividerCell = trim($dividerCell); if ($dividerCell === '') { continue; } $alignment = null; if ($dividerCell[ 0 ] === ':') { $alignment = 'left'; } if (substr($dividerCell, -1) === ':') { $alignment = $alignment === 'left' ? 'center' : 'right'; } $alignments[] = $alignment; } $headerElements = array(); $header = $block[ 'element' ][ 'text' ]; $header = trim($header); $header = trim($header, '|'); $headerCells = explode('|', $header); foreach ($headerCells as $index => $headerCell) { $headerCell = trim($headerCell); $headerElement = [ 'name' => 'th', 'text' => $headerCell, 'handler' => 'line', ]; if (isset($alignments[ $index ])) { $alignment = $alignments[ $index ]; $headerElement[ 'attributes' ] = [ 'style' => 'text-align: ' . $alignment . ';', ]; } $headerElements[] = $headerElement; } $block = [ 'alignments' => $alignments, 'identified' => true, 'element' => [ 'name' => 'table', 'handler' => 'elements', 'attributes' => [ 'class' => 'table table-striped table-bordered' ], ], ]; $block[ 'element' ][ 'text' ][] = [ 'name' => 'thead', 'handler' => 'elements', ]; $block[ 'element' ][ 'text' ][] = [ 'name' => 'tbody', 'handler' => 'elements', 'text' => array(), ]; $block[ 'element' ][ 'text' ][ 0 ][ 'text' ][] = [ 'name' => 'tr', 'handler' => 'elements', 'text' => $headerElements, ]; return $block; } }
[ "protected", "function", "blockTable", "(", "$", "line", ",", "array", "$", "block", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "block", ")", "or", "isset", "(", "$", "block", "[", "'type'", "]", ")", "or", "isset", "(", "$", "bloc...
Parse tables. @param array $line @param array $block @return array
[ "Parse", "tables", "." ]
448e1cdca18a8ffb6c08430cad8d22162171ac35
https://github.com/docit/core/blob/448e1cdca18a8ffb6c08430cad8d22162171ac35/src/Parsers/ParsedownExtra.php#L95-L190
train
teamelf/core
src/Http/AbstractController.php
AbstractController.validate
protected function validate(array $rules, bool $throwError = true) { $validations = []; $data = []; foreach ($rules as $key => $rule) { $value = $this->request->get($key); $violations = $this->validator->validate($value, $rule); if (count($violations) > 0) { $validations[$key] = []; foreach ($violations as $violation) { $validations[$key][] = $violation->getMessage(); } } else { $data[$key] = $value; } } if ($throwError && count($validations)) { throw new HttpValidationException($validations); } return $data; }
php
protected function validate(array $rules, bool $throwError = true) { $validations = []; $data = []; foreach ($rules as $key => $rule) { $value = $this->request->get($key); $violations = $this->validator->validate($value, $rule); if (count($violations) > 0) { $validations[$key] = []; foreach ($violations as $violation) { $validations[$key][] = $violation->getMessage(); } } else { $data[$key] = $value; } } if ($throwError && count($validations)) { throw new HttpValidationException($validations); } return $data; }
[ "protected", "function", "validate", "(", "array", "$", "rules", ",", "bool", "$", "throwError", "=", "true", ")", "{", "$", "validations", "=", "[", "]", ";", "$", "data", "=", "[", "]", ";", "foreach", "(", "$", "rules", "as", "$", "key", "=>", ...
validate input value from request @param array $rules ['key' => [new NotBlank(), ...], ...] @param bool $throwError @return array @throws HttpValidationException
[ "validate", "input", "value", "from", "request" ]
653fc6e27f42239c2a8998a5fea325480e9dd39e
https://github.com/teamelf/core/blob/653fc6e27f42239c2a8998a5fea325480e9dd39e/src/Http/AbstractController.php#L111-L131
train
teamelf/core
src/Http/AbstractController.php
AbstractController.auth
final protected function auth($member) { if ($member) { $this->session->set('auth_member_id', $member->getId()); } else { $this->session->remove('auth_member_id'); } return $this; }
php
final protected function auth($member) { if ($member) { $this->session->set('auth_member_id', $member->getId()); } else { $this->session->remove('auth_member_id'); } return $this; }
[ "final", "protected", "function", "auth", "(", "$", "member", ")", "{", "if", "(", "$", "member", ")", "{", "$", "this", "->", "session", "->", "set", "(", "'auth_member_id'", ",", "$", "member", "->", "getId", "(", ")", ")", ";", "}", "else", "{",...
set auth user to session @param null|Member $member @return $this
[ "set", "auth", "user", "to", "session" ]
653fc6e27f42239c2a8998a5fea325480e9dd39e
https://github.com/teamelf/core/blob/653fc6e27f42239c2a8998a5fea325480e9dd39e/src/Http/AbstractController.php#L139-L147
train
strident/Trident
src/Trident/Module/FrameworkModule/Debug/Toolbar/Extension/TridentMemoryUsageExtension.php
TridentMemoryUsageExtension.convertToBytes
private function convertToBytes($memoryLimit) { if ('-1' === $memoryLimit) { return -1; } $memoryLimit = strtolower($memoryLimit); $max = strtolower(ltrim($memoryLimit, '+')); if (0 === strpos($max, '0x')) { $max = intval($max, 16); } elseif (0 === strpos($max, '0')) { $max = intval($max, 8); } else { $max = intval($max); } switch (substr($memoryLimit, -1)) { case 't': $max *= 1024; case 'g': $max *= 1024; case 'm': $max *= 1024; case 'k': $max *= 1024; } return $max; }
php
private function convertToBytes($memoryLimit) { if ('-1' === $memoryLimit) { return -1; } $memoryLimit = strtolower($memoryLimit); $max = strtolower(ltrim($memoryLimit, '+')); if (0 === strpos($max, '0x')) { $max = intval($max, 16); } elseif (0 === strpos($max, '0')) { $max = intval($max, 8); } else { $max = intval($max); } switch (substr($memoryLimit, -1)) { case 't': $max *= 1024; case 'g': $max *= 1024; case 'm': $max *= 1024; case 'k': $max *= 1024; } return $max; }
[ "private", "function", "convertToBytes", "(", "$", "memoryLimit", ")", "{", "if", "(", "'-1'", "===", "$", "memoryLimit", ")", "{", "return", "-", "1", ";", "}", "$", "memoryLimit", "=", "strtolower", "(", "$", "memoryLimit", ")", ";", "$", "max", "=",...
Convert mixed to bytes. @param mixed $memoryLimit @return integer
[ "Convert", "mixed", "to", "bytes", "." ]
a112f0b75601b897c470a49d85791dc386c29952
https://github.com/strident/Trident/blob/a112f0b75601b897c470a49d85791dc386c29952/src/Trident/Module/FrameworkModule/Debug/Toolbar/Extension/TridentMemoryUsageExtension.php#L51-L75
train
n0m4dz/laracasa
src/N0m4dz/Laracasa/Laracasa.php
Laracasa.getAlbum
function getAlbum() { $photos = new Zend_Gdata_Photos($this->client); $query = new Zend_Gdata_Photos_AlbumQuery(); $query->setUser($this->user); $query->setAlbumId($this->album); $albumFeed = $photos->getAlbumFeed($query); return $albumFeed; }
php
function getAlbum() { $photos = new Zend_Gdata_Photos($this->client); $query = new Zend_Gdata_Photos_AlbumQuery(); $query->setUser($this->user); $query->setAlbumId($this->album); $albumFeed = $photos->getAlbumFeed($query); return $albumFeed; }
[ "function", "getAlbum", "(", ")", "{", "$", "photos", "=", "new", "Zend_Gdata_Photos", "(", "$", "this", "->", "client", ")", ";", "$", "query", "=", "new", "Zend_Gdata_Photos_AlbumQuery", "(", ")", ";", "$", "query", "->", "setUser", "(", "$", "this", ...
Retrieve photos from specified album
[ "Retrieve", "photos", "from", "specified", "album" ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/src/N0m4dz/Laracasa/Laracasa.php#L92-L99
train
n0m4dz/laracasa
src/N0m4dz/Laracasa/Laracasa.php
Laracasa.getPhotoById
function getPhotoById($photoId) { $photos = new Zend_Gdata_Photos($this->client); $query = new Zend_Gdata_Photos_PhotoQuery(); $query->setUser($this->user); $query->setAlbumId($this->album); $query->setPhotoId($photoId); $query = $query->getQueryUrl() . "?kind=comment,tag&imgmax=1600"; $photoFeed = $photos->getPhotoFeed($query); return $photoFeed; }
php
function getPhotoById($photoId) { $photos = new Zend_Gdata_Photos($this->client); $query = new Zend_Gdata_Photos_PhotoQuery(); $query->setUser($this->user); $query->setAlbumId($this->album); $query->setPhotoId($photoId); $query = $query->getQueryUrl() . "?kind=comment,tag&imgmax=1600"; $photoFeed = $photos->getPhotoFeed($query); return $photoFeed; }
[ "function", "getPhotoById", "(", "$", "photoId", ")", "{", "$", "photos", "=", "new", "Zend_Gdata_Photos", "(", "$", "this", "->", "client", ")", ";", "$", "query", "=", "new", "Zend_Gdata_Photos_PhotoQuery", "(", ")", ";", "$", "query", "->", "setUser", ...
Select a photo from specified album @param [string] $photoId [photo ID] @return [object] [return photo object]
[ "Select", "a", "photo", "from", "specified", "album" ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/src/N0m4dz/Laracasa/Laracasa.php#L106-L116
train
n0m4dz/laracasa
src/N0m4dz/Laracasa/Laracasa.php
Laracasa.addPhoto
function addPhoto($photo) { if (!file_exists($photo['tmp_name']) || !is_uploaded_file($photo['tmp_name'])) { $o = array('state' => false); } else { $photos = new Zend_Gdata_Photos($this->client); $fd = $photos->newMediaFileSource($photo["tmp_name"]); $fd->setContentType($photo["type"]); $entry = new Zend_Gdata_Photos_PhotoEntry(); $entry->setMediaSource($fd); $entry->setTitle($photos->newTitle($photo["name"])); $albumQuery = new Zend_Gdata_Photos_AlbumQuery; $albumQuery->setUser($this->user); $albumQuery->setAlbumId($this->album); $albumEntry = $photos->getAlbumEntry($albumQuery); $result = $photos->insertPhotoEntry($entry, $albumEntry); if ($result) { $o = array('state' => true, 'id' => $result->getGphotoId()); } else { $o = array('state' => false); } } return $o; }
php
function addPhoto($photo) { if (!file_exists($photo['tmp_name']) || !is_uploaded_file($photo['tmp_name'])) { $o = array('state' => false); } else { $photos = new Zend_Gdata_Photos($this->client); $fd = $photos->newMediaFileSource($photo["tmp_name"]); $fd->setContentType($photo["type"]); $entry = new Zend_Gdata_Photos_PhotoEntry(); $entry->setMediaSource($fd); $entry->setTitle($photos->newTitle($photo["name"])); $albumQuery = new Zend_Gdata_Photos_AlbumQuery; $albumQuery->setUser($this->user); $albumQuery->setAlbumId($this->album); $albumEntry = $photos->getAlbumEntry($albumQuery); $result = $photos->insertPhotoEntry($entry, $albumEntry); if ($result) { $o = array('state' => true, 'id' => $result->getGphotoId()); } else { $o = array('state' => false); } } return $o; }
[ "function", "addPhoto", "(", "$", "photo", ")", "{", "if", "(", "!", "file_exists", "(", "$", "photo", "[", "'tmp_name'", "]", ")", "||", "!", "is_uploaded_file", "(", "$", "photo", "[", "'tmp_name'", "]", ")", ")", "{", "$", "o", "=", "array", "("...
Add a photo to specific picasa web album @param [file] $photo [uploaded photo file object]
[ "Add", "a", "photo", "to", "specific", "picasa", "web", "album" ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/src/N0m4dz/Laracasa/Laracasa.php#L122-L150
train
n0m4dz/laracasa
src/N0m4dz/Laracasa/Laracasa.php
Laracasa.deletePhoto
function deletePhoto($photoId) { $photos = new Zend_Gdata_Photos($this->client); $photoQuery = new Zend_Gdata_Photos_PhotoQuery; $photoQuery->setUser($this->user); $photoQuery->setAlbumId($this->album); $photoQuery->setPhotoId($photoId); $photoQuery->setType('entry'); $entry = $photos->getPhotoEntry($photoQuery); $photos->deletePhotoEntry($entry, true); }
php
function deletePhoto($photoId) { $photos = new Zend_Gdata_Photos($this->client); $photoQuery = new Zend_Gdata_Photos_PhotoQuery; $photoQuery->setUser($this->user); $photoQuery->setAlbumId($this->album); $photoQuery->setPhotoId($photoId); $photoQuery->setType('entry'); $entry = $photos->getPhotoEntry($photoQuery); $photos->deletePhotoEntry($entry, true); }
[ "function", "deletePhoto", "(", "$", "photoId", ")", "{", "$", "photos", "=", "new", "Zend_Gdata_Photos", "(", "$", "this", "->", "client", ")", ";", "$", "photoQuery", "=", "new", "Zend_Gdata_Photos_PhotoQuery", ";", "$", "photoQuery", "->", "setUser", "(",...
Deletes the specified photo @param Zend_Http_Client $client The authenticated client @param string $user The user's account name @param integer $albumId The album's id @param integer $photoId The photo's id @return void
[ "Deletes", "the", "specified", "photo" ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/src/N0m4dz/Laracasa/Laracasa.php#L161-L173
train
native5/native5-sdk-common-php
src/Native5/Core/Configuration/YamlConfigFactory.php
YamlConfigFactory.override
public function override($configFile, $strict = false) { parent::override($this->_parse($configFile, $strict)); }
php
public function override($configFile, $strict = false) { parent::override($this->_parse($configFile, $strict)); }
[ "public", "function", "override", "(", "$", "configFile", ",", "$", "strict", "=", "false", ")", "{", "parent", "::", "override", "(", "$", "this", "->", "_parse", "(", "$", "configFile", ",", "$", "strict", ")", ")", ";", "}" ]
override Merges the configuration from this yaml file with the base configuration, override values @param mixed $config path to config file @param mixed $strict whether to throw an exception if file is not found @access public @return void
[ "override", "Merges", "the", "configuration", "from", "this", "yaml", "file", "with", "the", "base", "configuration", "override", "values" ]
c8bd5b219bd05ea4d317d21ae9c0c8dddcede7fe
https://github.com/native5/native5-sdk-common-php/blob/c8bd5b219bd05ea4d317d21ae9c0c8dddcede7fe/src/Native5/Core/Configuration/YamlConfigFactory.php#L68-L70
train
AnonymPHP/Anonym-Library
src/Anonym/Mail/PhpMailerDriver.php
PhpMailerDriver.from
public function from($mail, $name = null) { $this->mailer->setFrom($mail, $name); return $this; }
php
public function from($mail, $name = null) { $this->mailer->setFrom($mail, $name); return $this; }
[ "public", "function", "from", "(", "$", "mail", ",", "$", "name", "=", "null", ")", "{", "$", "this", "->", "mailer", "->", "setFrom", "(", "$", "mail", ",", "$", "name", ")", ";", "return", "$", "this", ";", "}" ]
Set the address information sent by mail. @param string $mail the address of mail @param string $name the real name of mail sender @return $this
[ "Set", "the", "address", "information", "sent", "by", "mail", "." ]
c967ad804f84e8fb204593a0959cda2fed5ae075
https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Mail/PhpMailerDriver.php#L90-L94
train
AnonymPHP/Anonym-Library
src/Anonym/Mail/PhpMailerDriver.php
PhpMailerDriver.body
public function body($body = '', $contentType = 'text/html') { $this->mailer->Body = $body; $this->mailer->ContentType = $contentType; return $this; }
php
public function body($body = '', $contentType = 'text/html') { $this->mailer->Body = $body; $this->mailer->ContentType = $contentType; return $this; }
[ "public", "function", "body", "(", "$", "body", "=", "''", ",", "$", "contentType", "=", "'text/html'", ")", "{", "$", "this", "->", "mailer", "->", "Body", "=", "$", "body", ";", "$", "this", "->", "mailer", "->", "ContentType", "=", "$", "contentTy...
register the message body @param string $body the message body @param string $contentType the type of message content @return $this
[ "register", "the", "message", "body" ]
c967ad804f84e8fb204593a0959cda2fed5ae075
https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Mail/PhpMailerDriver.php#L116-L121
train
eix/core
src/php/main/Eix/Core/Responses/Http.php
Http.issue
public function issue() { // If there is no next URL, just output the headers as expected. foreach ($this->headers as $key => $value) { header("{$key}: {$value}", true); } // Output content type. if ($this->contentType) { header("content-type: {$this->contentType}; charset={$this->encoding}"); } // Output status code. $statusMessage = sprintf('%d %s', $this->status, HttpClient::getStatusCodeMessage($this->status) ); header('Status: ' . $statusMessage); }
php
public function issue() { // If there is no next URL, just output the headers as expected. foreach ($this->headers as $key => $value) { header("{$key}: {$value}", true); } // Output content type. if ($this->contentType) { header("content-type: {$this->contentType}; charset={$this->encoding}"); } // Output status code. $statusMessage = sprintf('%d %s', $this->status, HttpClient::getStatusCodeMessage($this->status) ); header('Status: ' . $statusMessage); }
[ "public", "function", "issue", "(", ")", "{", "// If there is no next URL, just output the headers as expected.", "foreach", "(", "$", "this", "->", "headers", "as", "$", "key", "=>", "$", "value", ")", "{", "header", "(", "\"{$key}: {$value}\"", ",", "true", ")",...
The default output of an HTTP response is composed of the headers.
[ "The", "default", "output", "of", "an", "HTTP", "response", "is", "composed", "of", "the", "headers", "." ]
a5b4c09cc168221e85804fdfeb78e519a0415466
https://github.com/eix/core/blob/a5b4c09cc168221e85804fdfeb78e519a0415466/src/php/main/Eix/Core/Responses/Http.php#L36-L54
train
eix/core
src/php/main/Eix/Core/Responses/Http.php
Http.setStatus
public function setStatus($status) { $result = \Eix\Services\Net\Http::isStatusCodeValid($status); if ($result) { $this->status = $status; } return $result; }
php
public function setStatus($status) { $result = \Eix\Services\Net\Http::isStatusCodeValid($status); if ($result) { $this->status = $status; } return $result; }
[ "public", "function", "setStatus", "(", "$", "status", ")", "{", "$", "result", "=", "\\", "Eix", "\\", "Services", "\\", "Net", "\\", "Http", "::", "isStatusCodeValid", "(", "$", "status", ")", ";", "if", "(", "$", "result", ")", "{", "$", "this", ...
Sets the status, if it is a valid HTTP status code. @param int $status an integer representing a valid HTTP status code. @return boolean whether the status was set or not.
[ "Sets", "the", "status", "if", "it", "is", "a", "valid", "HTTP", "status", "code", "." ]
a5b4c09cc168221e85804fdfeb78e519a0415466
https://github.com/eix/core/blob/a5b4c09cc168221e85804fdfeb78e519a0415466/src/php/main/Eix/Core/Responses/Http.php#L102-L110
train
eix/core
src/php/main/Eix/Core/Responses/Http.php
Http.addStatusMessage
protected function addStatusMessage($type, $messages) { if (!is_array($messages)) { $messages = array($messages); } $this->addData('status', array($type => $messages)); }
php
protected function addStatusMessage($type, $messages) { if (!is_array($messages)) { $messages = array($messages); } $this->addData('status', array($type => $messages)); }
[ "protected", "function", "addStatusMessage", "(", "$", "type", ",", "$", "messages", ")", "{", "if", "(", "!", "is_array", "(", "$", "messages", ")", ")", "{", "$", "messages", "=", "array", "(", "$", "messages", ")", ";", "}", "$", "this", "->", "...
Adds one or more status messages to the response data. @param string $messages
[ "Adds", "one", "or", "more", "status", "messages", "to", "the", "response", "data", "." ]
a5b4c09cc168221e85804fdfeb78e519a0415466
https://github.com/eix/core/blob/a5b4c09cc168221e85804fdfeb78e519a0415466/src/php/main/Eix/Core/Responses/Http.php#L147-L153
train
yinheark/yincart2-framework
customer/models/Customer.php
Customer.findByPasswordResetToken
public static function findByPasswordResetToken($token) { $expire = Yii::$app->params['user.passwordResetTokenExpire']; $parts = explode('_', $token); $timestamp = (int) end($parts); if ($timestamp + $expire < time()) { // token expired return null; } return static::findOne([ 'password_reset_token' => $token, 'status' => self::STATUS_ACTIVE, ]); }
php
public static function findByPasswordResetToken($token) { $expire = Yii::$app->params['user.passwordResetTokenExpire']; $parts = explode('_', $token); $timestamp = (int) end($parts); if ($timestamp + $expire < time()) { // token expired return null; } return static::findOne([ 'password_reset_token' => $token, 'status' => self::STATUS_ACTIVE, ]); }
[ "public", "static", "function", "findByPasswordResetToken", "(", "$", "token", ")", "{", "$", "expire", "=", "Yii", "::", "$", "app", "->", "params", "[", "'user.passwordResetTokenExpire'", "]", ";", "$", "parts", "=", "explode", "(", "'_'", ",", "$", "tok...
Finds user by password reset token @param string $token password reset token @return static|null
[ "Finds", "user", "by", "password", "reset", "token" ]
c37421924abeba63337c685bfa31ece9997ac27d
https://github.com/yinheark/yincart2-framework/blob/c37421924abeba63337c685bfa31ece9997ac27d/customer/models/Customer.php#L170-L184
train
phox-pro/pulsar-core
src/database/migrations/2018_07_06_105139_create_configs_tables.php
CreateConfigsTables.categories
private function categories() { $package = Package::where('name', 'Core')->first(); $core = ConfigCategory::create([ 'key' => 'core', 'package_id' => $package->id ]); ConfigCategory::create([ 'key' => 'core_mail', 'parent_id' => $core->id, 'package_id' => $core->package_id ]); ConfigCategory::create([ 'key' => 'core_general', 'parent_id' => $core->id, 'package_id' => $core->package_id ]); $this->general(); $this->mail(); }
php
private function categories() { $package = Package::where('name', 'Core')->first(); $core = ConfigCategory::create([ 'key' => 'core', 'package_id' => $package->id ]); ConfigCategory::create([ 'key' => 'core_mail', 'parent_id' => $core->id, 'package_id' => $core->package_id ]); ConfigCategory::create([ 'key' => 'core_general', 'parent_id' => $core->id, 'package_id' => $core->package_id ]); $this->general(); $this->mail(); }
[ "private", "function", "categories", "(", ")", "{", "$", "package", "=", "Package", "::", "where", "(", "'name'", ",", "'Core'", ")", "->", "first", "(", ")", ";", "$", "core", "=", "ConfigCategory", "::", "create", "(", "[", "'key'", "=>", "'core'", ...
Method for creating configuration categories @return void
[ "Method", "for", "creating", "configuration", "categories" ]
fa9c66f6578180253a65c91edf422fc3c51b32ba
https://github.com/phox-pro/pulsar-core/blob/fa9c66f6578180253a65c91edf422fc3c51b32ba/src/database/migrations/2018_07_06_105139_create_configs_tables.php#L62-L81
train
extendsframework/extends-router
src/Framework/ServiceLocator/Factory/RouterFactory.php
RouterFactory.createService
public function createService(string $key, ServiceLocatorInterface $serviceLocator, array $extra = null): object { $config = $serviceLocator->getConfig(); $config = $config[RouterInterface::class] ?? []; $router = new Router(); foreach ($config['routes'] ?? [] as $name => $config) { $router->addRoute( $this->createRoute($serviceLocator, $config), $name ); } return $router; }
php
public function createService(string $key, ServiceLocatorInterface $serviceLocator, array $extra = null): object { $config = $serviceLocator->getConfig(); $config = $config[RouterInterface::class] ?? []; $router = new Router(); foreach ($config['routes'] ?? [] as $name => $config) { $router->addRoute( $this->createRoute($serviceLocator, $config), $name ); } return $router; }
[ "public", "function", "createService", "(", "string", "$", "key", ",", "ServiceLocatorInterface", "$", "serviceLocator", ",", "array", "$", "extra", "=", "null", ")", ":", "object", "{", "$", "config", "=", "$", "serviceLocator", "->", "getConfig", "(", ")",...
Create router. @param string $key @param ServiceLocatorInterface $serviceLocator @param array|null $extra @return RouterInterface @throws ServiceLocatorException
[ "Create", "router", "." ]
7c142749635c6fb1c58508bf3c8f594529e136d9
https://github.com/extendsframework/extends-router/blob/7c142749635c6fb1c58508bf3c8f594529e136d9/src/Framework/ServiceLocator/Factory/RouterFactory.php#L25-L39
train
extendsframework/extends-router
src/Framework/ServiceLocator/Factory/RouterFactory.php
RouterFactory.createGroup
protected function createGroup( ServiceLocatorInterface $serviceLocator, RouteInterface $route, array $children, bool $abstract = null ): RouteInterface { /** @var GroupRoute $group */ $group = $serviceLocator->getService(GroupRoute::class, [ 'route' => $route, 'abstract' => $abstract, ]); foreach ($children as $name => $child) { $group->addRoute( $this->createRoute($serviceLocator, $child), $name ); } return $group; }
php
protected function createGroup( ServiceLocatorInterface $serviceLocator, RouteInterface $route, array $children, bool $abstract = null ): RouteInterface { /** @var GroupRoute $group */ $group = $serviceLocator->getService(GroupRoute::class, [ 'route' => $route, 'abstract' => $abstract, ]); foreach ($children as $name => $child) { $group->addRoute( $this->createRoute($serviceLocator, $child), $name ); } return $group; }
[ "protected", "function", "createGroup", "(", "ServiceLocatorInterface", "$", "serviceLocator", ",", "RouteInterface", "$", "route", ",", "array", "$", "children", ",", "bool", "$", "abstract", "=", "null", ")", ":", "RouteInterface", "{", "/** @var GroupRoute $group...
Create group route. @param ServiceLocatorInterface $serviceLocator @param RouteInterface $route @param array $children @param bool|null $abstract @return RouteInterface @throws ServiceLocatorException
[ "Create", "group", "route", "." ]
7c142749635c6fb1c58508bf3c8f594529e136d9
https://github.com/extendsframework/extends-router/blob/7c142749635c6fb1c58508bf3c8f594529e136d9/src/Framework/ServiceLocator/Factory/RouterFactory.php#L69-L89
train
malenkiki/argile
src/Malenki/Argile/Options.php
Options.addGroup
public function addGroup($str_alias, $str_name = null) { if (!isset(self::$arr_group[$str_alias])) { $grp = new \stdClass(); $grp->name = (strlen($str_name)) ? $str_name : null; $grp->args = array(); self::$arr_group[$str_alias] = $grp; } return $this; }
php
public function addGroup($str_alias, $str_name = null) { if (!isset(self::$arr_group[$str_alias])) { $grp = new \stdClass(); $grp->name = (strlen($str_name)) ? $str_name : null; $grp->args = array(); self::$arr_group[$str_alias] = $grp; } return $this; }
[ "public", "function", "addGroup", "(", "$", "str_alias", ",", "$", "str_name", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "arr_group", "[", "$", "str_alias", "]", ")", ")", "{", "$", "grp", "=", "new", "\\", "stdClass",...
Adds a new group for options. @param string $str_alias Conding name of the group, to identify it when defining options. @param string $str_name Optional name to display while rendering help. @access public @return Options
[ "Adds", "a", "new", "group", "for", "options", "." ]
be54afe78b3dfc0122c83b38eb134f8445357f7e
https://github.com/malenkiki/argile/blob/be54afe78b3dfc0122c83b38eb134f8445357f7e/src/Malenki/Argile/Options.php#L350-L361
train
malenkiki/argile
src/Malenki/Argile/Options.php
Options.add
public static function add(OptionItem $opt, $str_alias = null) { // tester ici si version ou aide : à ne pas mettre if( !in_array($opt->getShort(true), self::$arr_prohibited, true) && !in_array($opt->getLong(true), self::$arr_prohibited, true) ) { if (is_string($str_alias) && isset(self::$arr_group[$str_alias])) { self::$arr_group[$str_alias]->args[$opt->getName()] = $opt; } else { self::$arr_opt[$opt->getName()] = $opt; } } }
php
public static function add(OptionItem $opt, $str_alias = null) { // tester ici si version ou aide : à ne pas mettre if( !in_array($opt->getShort(true), self::$arr_prohibited, true) && !in_array($opt->getLong(true), self::$arr_prohibited, true) ) { if (is_string($str_alias) && isset(self::$arr_group[$str_alias])) { self::$arr_group[$str_alias]->args[$opt->getName()] = $opt; } else { self::$arr_opt[$opt->getName()] = $opt; } } }
[ "public", "static", "function", "add", "(", "OptionItem", "$", "opt", ",", "$", "str_alias", "=", "null", ")", "{", "// tester ici si version ou aide : à ne pas mettre", "if", "(", "!", "in_array", "(", "$", "opt", "->", "getShort", "(", "true", ")", ",", "s...
Adds one new option. @param OptionItem $opt The option. @param mixed $str_alias Its optional group's alias. @static @access public @return void
[ "Adds", "one", "new", "option", "." ]
be54afe78b3dfc0122c83b38eb134f8445357f7e
https://github.com/malenkiki/argile/blob/be54afe78b3dfc0122c83b38eb134f8445357f7e/src/Malenki/Argile/Options.php#L372-L387
train
malenkiki/argile
src/Malenki/Argile/Options.php
Options.newSwitch
public function newSwitch($name, $group = null) { $arg = OptionItem::createSwitch($name); if ($this->obj_color->opt) { $arg->color($this->obj_color->opt); } if ($this->obj_color->bold) { $arg->bold(); } self::add($arg, $group); return self::getOpt($name); }
php
public function newSwitch($name, $group = null) { $arg = OptionItem::createSwitch($name); if ($this->obj_color->opt) { $arg->color($this->obj_color->opt); } if ($this->obj_color->bold) { $arg->bold(); } self::add($arg, $group); return self::getOpt($name); }
[ "public", "function", "newSwitch", "(", "$", "name", ",", "$", "group", "=", "null", ")", "{", "$", "arg", "=", "OptionItem", "::", "createSwitch", "(", "$", "name", ")", ";", "if", "(", "$", "this", "->", "obj_color", "->", "opt", ")", "{", "$", ...
Adds a new option switch. @param string $name The string to identify and call this option. @param string $group Optional group's name @access public @return OptionItem The newly created option, to chain methods.
[ "Adds", "a", "new", "option", "switch", "." ]
be54afe78b3dfc0122c83b38eb134f8445357f7e
https://github.com/malenkiki/argile/blob/be54afe78b3dfc0122c83b38eb134f8445357f7e/src/Malenki/Argile/Options.php#L442-L457
train
malenkiki/argile
src/Malenki/Argile/Options.php
Options.newValue
public function newValue($name, $group = null) { $arg = OptionItem::createValue($name); if ($this->obj_color->opt) { $arg->color($this->obj_color->opt); } if ($this->obj_color->bold) { $arg->bold(); } self::add($arg, $group); return self::getOpt($name); }
php
public function newValue($name, $group = null) { $arg = OptionItem::createValue($name); if ($this->obj_color->opt) { $arg->color($this->obj_color->opt); } if ($this->obj_color->bold) { $arg->bold(); } self::add($arg, $group); return self::getOpt($name); }
[ "public", "function", "newValue", "(", "$", "name", ",", "$", "group", "=", "null", ")", "{", "$", "arg", "=", "OptionItem", "::", "createValue", "(", "$", "name", ")", ";", "if", "(", "$", "this", "->", "obj_color", "->", "opt", ")", "{", "$", "...
Adds a new option's value. @param string $name Option's name. @param string $group Optional group's name. @access public @return OptionItem
[ "Adds", "a", "new", "option", "s", "value", "." ]
be54afe78b3dfc0122c83b38eb134f8445357f7e
https://github.com/malenkiki/argile/blob/be54afe78b3dfc0122c83b38eb134f8445357f7e/src/Malenki/Argile/Options.php#L467-L482
train
malenkiki/argile
src/Malenki/Argile/Options.php
Options.getDescription
public function getDescription() { if (is_string($this->str_description)) { $description = new S($this->str_description); return $description->wrap(OptionItem::getWidth()); } else { return null; } }
php
public function getDescription() { if (is_string($this->str_description)) { $description = new S($this->str_description); return $description->wrap(OptionItem::getWidth()); } else { return null; } }
[ "public", "function", "getDescription", "(", ")", "{", "if", "(", "is_string", "(", "$", "this", "->", "str_description", ")", ")", "{", "$", "description", "=", "new", "S", "(", "$", "this", "->", "str_description", ")", ";", "return", "$", "description...
Getsthe description part. This follows terminal size or not if `flexible()` method was called or not before. @access public @return string
[ "Getsthe", "description", "part", "." ]
be54afe78b3dfc0122c83b38eb134f8445357f7e
https://github.com/malenkiki/argile/blob/be54afe78b3dfc0122c83b38eb134f8445357f7e/src/Malenki/Argile/Options.php#L533-L542
train
malenkiki/argile
src/Malenki/Argile/Options.php
Options.displayHelp
public function displayHelp() { printf("%s\n", $this->getUsage()); printf("%s\n", $this->getDescription()); // Les options non incluses dans un groupe if (count(self::$arr_opt)) { foreach (self::$arr_opt as $arg) { printf("%s\n", rtrim($arg)); } } // Options faisant partie d’un groupe if (count(self::$arr_group)) { foreach (self::$arr_group as $group) { if (count($group->args)) { print("\n\n"); if ($group->name) { $name = $group->name; if ($this->obj_color->label || $this->obj_color->bold) { $name = new Ansi($name); if ($this->obj_color->label) { $name->fg($this->obj_color->label); } if ($this->obj_color->bold) { $name->bold; } } printf("%s\n", $name); } foreach ($group->args as $arg) { printf("%s\n", rtrim($arg)); } } } } exit(); }
php
public function displayHelp() { printf("%s\n", $this->getUsage()); printf("%s\n", $this->getDescription()); // Les options non incluses dans un groupe if (count(self::$arr_opt)) { foreach (self::$arr_opt as $arg) { printf("%s\n", rtrim($arg)); } } // Options faisant partie d’un groupe if (count(self::$arr_group)) { foreach (self::$arr_group as $group) { if (count($group->args)) { print("\n\n"); if ($group->name) { $name = $group->name; if ($this->obj_color->label || $this->obj_color->bold) { $name = new Ansi($name); if ($this->obj_color->label) { $name->fg($this->obj_color->label); } if ($this->obj_color->bold) { $name->bold; } } printf("%s\n", $name); } foreach ($group->args as $arg) { printf("%s\n", rtrim($arg)); } } } } exit(); }
[ "public", "function", "displayHelp", "(", ")", "{", "printf", "(", "\"%s\\n\"", ",", "$", "this", "->", "getUsage", "(", ")", ")", ";", "printf", "(", "\"%s\\n\"", ",", "$", "this", "->", "getDescription", "(", ")", ")", ";", "// Les options non incluses d...
Displays full help message. This follows terminal size or not if `flexible()` method was called or not before. @access public @return void
[ "Displays", "full", "help", "message", "." ]
be54afe78b3dfc0122c83b38eb134f8445357f7e
https://github.com/malenkiki/argile/blob/be54afe78b3dfc0122c83b38eb134f8445357f7e/src/Malenki/Argile/Options.php#L554-L598
train
unyx/connect
streams/Stream.php
Stream.refresh
protected function refresh() : bool { // Without a resource to grab the metadata for, let invokers know there's no data // to work with presently. if (!$this->resource) { return false; } // Prepare the status mask if necessary. Might as well give it a value to begin with. if (!$this->status) { $this->status = new core\Mask(stream_is_local($this->resource) ? interfaces\Stream::LOCAL : 0); } // The call results of metadata() are cached so we can just use the class property. $this->getMetadata(); if (isset(self::$rwh['read'][$this->metadata['mode']])) { $this->status->set(interfaces\Stream::READABLE); } if (isset(self::$rwh['write'][$this->metadata['mode']])) { $this->status->set(interfaces\Stream::WRITABLE); } // Those may change, so... besides - fancy syntax, eh chaps? $this->status->{((isset($this->metadata['seekable']) && $this->metadata['seekable']) ? 'set' : 'remove')}(interfaces\Stream::SEEKABLE); $this->status->{((isset($this->metadata['blocked']) && $this->metadata['blocked']) ? 'set' : 'remove')}(interfaces\Stream::BLOCKED); return true; }
php
protected function refresh() : bool { // Without a resource to grab the metadata for, let invokers know there's no data // to work with presently. if (!$this->resource) { return false; } // Prepare the status mask if necessary. Might as well give it a value to begin with. if (!$this->status) { $this->status = new core\Mask(stream_is_local($this->resource) ? interfaces\Stream::LOCAL : 0); } // The call results of metadata() are cached so we can just use the class property. $this->getMetadata(); if (isset(self::$rwh['read'][$this->metadata['mode']])) { $this->status->set(interfaces\Stream::READABLE); } if (isset(self::$rwh['write'][$this->metadata['mode']])) { $this->status->set(interfaces\Stream::WRITABLE); } // Those may change, so... besides - fancy syntax, eh chaps? $this->status->{((isset($this->metadata['seekable']) && $this->metadata['seekable']) ? 'set' : 'remove')}(interfaces\Stream::SEEKABLE); $this->status->{((isset($this->metadata['blocked']) && $this->metadata['blocked']) ? 'set' : 'remove')}(interfaces\Stream::BLOCKED); return true; }
[ "protected", "function", "refresh", "(", ")", ":", "bool", "{", "// Without a resource to grab the metadata for, let invokers know there's no data", "// to work with presently.", "if", "(", "!", "$", "this", "->", "resource", ")", "{", "return", "false", ";", "}", "// P...
Refreshes the status mask based on the current metadata of the stream. @return bool True if we successfully refreshed all relevant data, false otherwise.
[ "Refreshes", "the", "status", "mask", "based", "on", "the", "current", "metadata", "of", "the", "stream", "." ]
462b9e1318af3a7db28ddc89cd2a49ef71439c1b
https://github.com/unyx/connect/blob/462b9e1318af3a7db28ddc89cd2a49ef71439c1b/streams/Stream.php#L436-L465
train
Sowapps/orpheus-inputcontroller
src/InputController/HTTPController/JSONHTTPResponse.php
JSONHTTPResponse.render
public static function render($textCode, $other=null, $domain='global', $description=null) { $response = new static(); $response->collectFrom($textCode, $other, $domain, $description); return $response; }
php
public static function render($textCode, $other=null, $domain='global', $description=null) { $response = new static(); $response->collectFrom($textCode, $other, $domain, $description); return $response; }
[ "public", "static", "function", "render", "(", "$", "textCode", ",", "$", "other", "=", "null", ",", "$", "domain", "=", "'global'", ",", "$", "description", "=", "null", ")", "{", "$", "response", "=", "new", "static", "(", ")", ";", "$", "response"...
Render the given data @param string $textCode @param mixed $other @param string $domain @param string $description @return \Orpheus\InputController\HTTPController\JSONHTTPResponse @see \Orpheus\InputController\HTTPController\JSONHTTPResponse::returnData() We recommend to use returnData() to return data, that is more RESTful and to use this method only for errors
[ "Render", "the", "given", "data" ]
91f848a42ac02ae4009ffb3e9a9b4e8c0731455e
https://github.com/Sowapps/orpheus-inputcontroller/blob/91f848a42ac02ae4009ffb3e9a9b4e8c0731455e/src/InputController/HTTPController/JSONHTTPResponse.php#L78-L82
train
dflydev/dflydev-identity-generator
src/Dflydev/IdentityGenerator/IdentityGenerator.php
IdentityGenerator.generate
public function generate($suggestion = null) { if (null !== $suggestion) { $this->dataStore->storeIdentity($suggestion, $this->mob); return $suggestion; } $exceptions = array(); for ($i = 0; $i <= $this->maxRetries; $i++) { $generatedIdentity = null; try { $generatedIdentity = $this->generator->generateIdentity(); $this->dataStore->storeIdentity($generatedIdentity, $this->mob); return $generatedIdentity; } catch (NonUniqueIdentityException $e) { // We expect non unique identity exceptions so this is fine. // Collect them and move on and try again if we still have // some tries left. $exceptions[] = $e; } catch (\Exception $e) { // All other exceptions are unexpected. throw new GenerateException($generatedIdentity, $this->mob, $exceptions, $e); } } throw new GenerateException(null, $this->mob, $exceptions); }
php
public function generate($suggestion = null) { if (null !== $suggestion) { $this->dataStore->storeIdentity($suggestion, $this->mob); return $suggestion; } $exceptions = array(); for ($i = 0; $i <= $this->maxRetries; $i++) { $generatedIdentity = null; try { $generatedIdentity = $this->generator->generateIdentity(); $this->dataStore->storeIdentity($generatedIdentity, $this->mob); return $generatedIdentity; } catch (NonUniqueIdentityException $e) { // We expect non unique identity exceptions so this is fine. // Collect them and move on and try again if we still have // some tries left. $exceptions[] = $e; } catch (\Exception $e) { // All other exceptions are unexpected. throw new GenerateException($generatedIdentity, $this->mob, $exceptions, $e); } } throw new GenerateException(null, $this->mob, $exceptions); }
[ "public", "function", "generate", "(", "$", "suggestion", "=", "null", ")", "{", "if", "(", "null", "!==", "$", "suggestion", ")", "{", "$", "this", "->", "dataStore", "->", "storeIdentity", "(", "$", "suggestion", ",", "$", "this", "->", "mob", ")", ...
Generate an identity string @param string|null $suggestion @return string @throws \Dflydev\IdentityGenerator\Exception\Exception
[ "Generate", "an", "identity", "string" ]
2479dad10002f26229d08899142d46d6f6b2dc0b
https://github.com/dflydev/dflydev-identity-generator/blob/2479dad10002f26229d08899142d46d6f6b2dc0b/src/Dflydev/IdentityGenerator/IdentityGenerator.php#L52-L80
train
sndatabase/core
src/Transaction.php
Transaction.rollBack
public function rollBack() { return $this->inTransaction ? ($this->in = $this->doRollBack($this->name)) : false; }
php
public function rollBack() { return $this->inTransaction ? ($this->in = $this->doRollBack($this->name)) : false; }
[ "public", "function", "rollBack", "(", ")", "{", "return", "$", "this", "->", "inTransaction", "?", "(", "$", "this", "->", "in", "=", "$", "this", "->", "doRollBack", "(", "$", "this", "->", "name", ")", ")", ":", "false", ";", "}" ]
Rolls back changes @return boolean Rollback success @throws DBException
[ "Rolls", "back", "changes" ]
8645b71f1cb437a845fcf12ae742655dd874b229
https://github.com/sndatabase/core/blob/8645b71f1cb437a845fcf12ae742655dd874b229/src/Transaction.php#L113-L115
train
znframework/package-language
Insert.php
Insert.do
public function do(String $app, $key, String $data = NULL) : Bool { $datas = []; $createFile = $this->_langFile($app); if( ! is_file($createFile) ) { file_put_contents($createFile, json_encode([])); } $datas = json_decode(file_get_contents($createFile), true); if( ! empty($datas) ) { $json = $datas; } if( ! is_array($key) ) { $json[$key] = $data; } else { foreach( $key as $k => $v ) { $json[$k] = $v; } } if( $json !== $datas ) { return file_put_contents($createFile, json_encode($json, JSON_UNESCAPED_UNICODE)); } else { return false; } }
php
public function do(String $app, $key, String $data = NULL) : Bool { $datas = []; $createFile = $this->_langFile($app); if( ! is_file($createFile) ) { file_put_contents($createFile, json_encode([])); } $datas = json_decode(file_get_contents($createFile), true); if( ! empty($datas) ) { $json = $datas; } if( ! is_array($key) ) { $json[$key] = $data; } else { foreach( $key as $k => $v ) { $json[$k] = $v; } } if( $json !== $datas ) { return file_put_contents($createFile, json_encode($json, JSON_UNESCAPED_UNICODE)); } else { return false; } }
[ "public", "function", "do", "(", "String", "$", "app", ",", "$", "key", ",", "String", "$", "data", "=", "NULL", ")", ":", "Bool", "{", "$", "datas", "=", "[", "]", ";", "$", "createFile", "=", "$", "this", "->", "_langFile", "(", "$", "app", "...
Insert language key @param string $app = NULL @param mixed $key @param string $data = NULL @return bool
[ "Insert", "language", "key" ]
f0fe3b9ec2ba1a69838da9af58ced5398ea9fb09
https://github.com/znframework/package-language/blob/f0fe3b9ec2ba1a69838da9af58ced5398ea9fb09/Insert.php#L23-L61
train
mszewcz/php-light-framework
src/Db/MySQL/Query/Utilities/Escape.php
Escape.doNotEscape
public function doNotEscape($doNotEscape = []): void { $this->doNotEscape = \array_unique(\array_merge($this->doNotEscape, $doNotEscape)); }
php
public function doNotEscape($doNotEscape = []): void { $this->doNotEscape = \array_unique(\array_merge($this->doNotEscape, $doNotEscape)); }
[ "public", "function", "doNotEscape", "(", "$", "doNotEscape", "=", "[", "]", ")", ":", "void", "{", "$", "this", "->", "doNotEscape", "=", "\\", "array_unique", "(", "\\", "array_merge", "(", "$", "this", "->", "doNotEscape", ",", "$", "doNotEscape", ")"...
Adds no quotable expressions @param array $doNotEscape
[ "Adds", "no", "quotable", "expressions" ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Db/MySQL/Query/Utilities/Escape.php#L45-L48
train
mszewcz/php-light-framework
src/Db/MySQL/Query/Utilities/Escape.php
Escape.escape
public function escape($value = null, array $doNotEscape = []) { $this->doNotEscape = \array_unique(\array_merge($this->doNotEscape, $doNotEscape)); if (\is_null($value)) { return 'NULL'; } if (\is_int($value) || \is_float($value)) { return $value; } if (\is_array($value) || \is_object($value)) { return $this->dbClass->escape(\serialize($value)); } foreach ($this->doNotEscape as $doNotEscape) { if (\preg_match('/^'.\str_replace('*', '\\*', $doNotEscape).'/i', (string)$value)) { return $value; } } return $this->dbClass->escape($value); }
php
public function escape($value = null, array $doNotEscape = []) { $this->doNotEscape = \array_unique(\array_merge($this->doNotEscape, $doNotEscape)); if (\is_null($value)) { return 'NULL'; } if (\is_int($value) || \is_float($value)) { return $value; } if (\is_array($value) || \is_object($value)) { return $this->dbClass->escape(\serialize($value)); } foreach ($this->doNotEscape as $doNotEscape) { if (\preg_match('/^'.\str_replace('*', '\\*', $doNotEscape).'/i', (string)$value)) { return $value; } } return $this->dbClass->escape($value); }
[ "public", "function", "escape", "(", "$", "value", "=", "null", ",", "array", "$", "doNotEscape", "=", "[", "]", ")", "{", "$", "this", "->", "doNotEscape", "=", "\\", "array_unique", "(", "\\", "array_merge", "(", "$", "this", "->", "doNotEscape", ","...
Escapes value using database specific method @param mixed|null $value @param array $doNotEscape @return mixed
[ "Escapes", "value", "using", "database", "specific", "method" ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Db/MySQL/Query/Utilities/Escape.php#L57-L77
train
zepi/turbo-base
Zepi/Web/UserInterface/src/Form/Field/DynamicZone.php
DynamicZone.getTriggerHtmlId
public function getTriggerHtmlId() { $form = $this->getParentOfType('\\Zepi\\Web\\UserInterface\\Form\Form'); if (is_object($form)) { $part = $form->searchPartByKeyAndType($this->triggerKey); return $part->getHtmlId(); } return ''; }
php
public function getTriggerHtmlId() { $form = $this->getParentOfType('\\Zepi\\Web\\UserInterface\\Form\Form'); if (is_object($form)) { $part = $form->searchPartByKeyAndType($this->triggerKey); return $part->getHtmlId(); } return ''; }
[ "public", "function", "getTriggerHtmlId", "(", ")", "{", "$", "form", "=", "$", "this", "->", "getParentOfType", "(", "'\\\\Zepi\\\\Web\\\\UserInterface\\\\Form\\Form'", ")", ";", "if", "(", "is_object", "(", "$", "form", ")", ")", "{", "$", "part", "=", "$"...
Returns the html id of the trigger element @access public @return string
[ "Returns", "the", "html", "id", "of", "the", "trigger", "element" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/UserInterface/src/Form/Field/DynamicZone.php#L131-L141
train
flowcode/ceibo
src/flowcode/ceibo/domain/Query.php
Query.AndWhere
public function AndWhere($condition, array $values) { $this->andWheres[] = $condition; $this->addBindValues($values); return $this; }
php
public function AndWhere($condition, array $values) { $this->andWheres[] = $condition; $this->addBindValues($values); return $this; }
[ "public", "function", "AndWhere", "(", "$", "condition", ",", "array", "$", "values", ")", "{", "$", "this", "->", "andWheres", "[", "]", "=", "$", "condition", ";", "$", "this", "->", "addBindValues", "(", "$", "values", ")", ";", "return", "$", "th...
Add an And Where condition to the query. @param string $condition @param array $values @return Query same instace.
[ "Add", "an", "And", "Where", "condition", "to", "the", "query", "." ]
ba264dc681a9d803885fd35d10b0e37776f66659
https://github.com/flowcode/ceibo/blob/ba264dc681a9d803885fd35d10b0e37776f66659/src/flowcode/ceibo/domain/Query.php#L39-L43
train
flowcode/ceibo
src/flowcode/ceibo/domain/Query.php
Query.Where
public function Where($condition, $values) { $this->setWhere($condition); $this->addBindValues($values); return $this; }
php
public function Where($condition, $values) { $this->setWhere($condition); $this->addBindValues($values); return $this; }
[ "public", "function", "Where", "(", "$", "condition", ",", "$", "values", ")", "{", "$", "this", "->", "setWhere", "(", "$", "condition", ")", ";", "$", "this", "->", "addBindValues", "(", "$", "values", ")", ";", "return", "$", "this", ";", "}" ]
Set where condition of the query. @param string $condition @param array $values @return Query same instace.
[ "Set", "where", "condition", "of", "the", "query", "." ]
ba264dc681a9d803885fd35d10b0e37776f66659
https://github.com/flowcode/ceibo/blob/ba264dc681a9d803885fd35d10b0e37776f66659/src/flowcode/ceibo/domain/Query.php#L68-L72
train
flowcode/ceibo
src/flowcode/ceibo/domain/Query.php
Query.execute
public function execute() { $statement = $this->buildStatement(); $result = $this->getDataSource()->query($statement, $this->getBindValues()); if ($result) { $collection = new Collection($this->getMapper()->getClass(), $result, $this->getMapper()); } else { $collection = new Collection($this->getMapper()->getClass(), array(), $this->getMapper()); } return $collection; }
php
public function execute() { $statement = $this->buildStatement(); $result = $this->getDataSource()->query($statement, $this->getBindValues()); if ($result) { $collection = new Collection($this->getMapper()->getClass(), $result, $this->getMapper()); } else { $collection = new Collection($this->getMapper()->getClass(), array(), $this->getMapper()); } return $collection; }
[ "public", "function", "execute", "(", ")", "{", "$", "statement", "=", "$", "this", "->", "buildStatement", "(", ")", ";", "$", "result", "=", "$", "this", "->", "getDataSource", "(", ")", "->", "query", "(", "$", "statement", ",", "$", "this", "->",...
Execute query and return a collection. @return Collection collection.
[ "Execute", "query", "and", "return", "a", "collection", "." ]
ba264dc681a9d803885fd35d10b0e37776f66659
https://github.com/flowcode/ceibo/blob/ba264dc681a9d803885fd35d10b0e37776f66659/src/flowcode/ceibo/domain/Query.php#L100-L110
train
yii2-tools/yii2-base
components/DbCommand.php
DbCommand.queryInternal
protected function queryInternal($method, $fetchMode = null) { if ($method !== '') { $rawSql = $this->getRawSql(); $requestLocalCacheKey = implode('', [ __CLASS__, $method, $fetchMode, $this->db->dsn, $this->db->username, preg_replace('/\s+/', '', $rawSql) ]); mb_convert_encoding($requestLocalCacheKey, 'UTF-8', 'UTF-8'); if (($result = static::$requestLocalCache->get($requestLocalCacheKey)) !== false) { Yii::info('Query result served from request local cache' . PHP_EOL . 'Query: ' . VarDumper::dumpAsString($rawSql) . PHP_EOL . 'Result: ' . VarDumper::dumpAsString($result), __METHOD__); return $result; } static::$requestLocalCache->set('rawSql', $rawSql); } $result = parent::queryInternal($method, $fetchMode); if ($method !== '') { static::$requestLocalCache->set($requestLocalCacheKey, $result); } return $result; }
php
protected function queryInternal($method, $fetchMode = null) { if ($method !== '') { $rawSql = $this->getRawSql(); $requestLocalCacheKey = implode('', [ __CLASS__, $method, $fetchMode, $this->db->dsn, $this->db->username, preg_replace('/\s+/', '', $rawSql) ]); mb_convert_encoding($requestLocalCacheKey, 'UTF-8', 'UTF-8'); if (($result = static::$requestLocalCache->get($requestLocalCacheKey)) !== false) { Yii::info('Query result served from request local cache' . PHP_EOL . 'Query: ' . VarDumper::dumpAsString($rawSql) . PHP_EOL . 'Result: ' . VarDumper::dumpAsString($result), __METHOD__); return $result; } static::$requestLocalCache->set('rawSql', $rawSql); } $result = parent::queryInternal($method, $fetchMode); if ($method !== '') { static::$requestLocalCache->set($requestLocalCacheKey, $result); } return $result; }
[ "protected", "function", "queryInternal", "(", "$", "method", ",", "$", "fetchMode", "=", "null", ")", "{", "if", "(", "$", "method", "!==", "''", ")", "{", "$", "rawSql", "=", "$", "this", "->", "getRawSql", "(", ")", ";", "$", "requestLocalCacheKey",...
Actual query with caching results in local for current request @inheritdoc
[ "Actual", "query", "with", "caching", "results", "in", "local", "for", "current", "request" ]
10f6bb6b0b9396c3d942e0f2ec06784fa9bbf72a
https://github.com/yii2-tools/yii2-base/blob/10f6bb6b0b9396c3d942e0f2ec06784fa9bbf72a/components/DbCommand.php#L72-L102
train
tarsana/filesystem
src/Adapters/Local.php
Local.isAbsolute
public function isAbsolute($path) { $firstChar = substr($path, 0, 1); if ('/' === $firstChar || '\\' === $firstChar) { return true; } $isLetter = ( ($firstChar >= 'A' && $firstChar <= 'Z') || ($firstChar >= 'a' && $firstChar <= 'z') ); $path = substr($path, 1, 2); return $isLetter && (':/' === $path || ':\\' === $path); }
php
public function isAbsolute($path) { $firstChar = substr($path, 0, 1); if ('/' === $firstChar || '\\' === $firstChar) { return true; } $isLetter = ( ($firstChar >= 'A' && $firstChar <= 'Z') || ($firstChar >= 'a' && $firstChar <= 'z') ); $path = substr($path, 1, 2); return $isLetter && (':/' === $path || ':\\' === $path); }
[ "public", "function", "isAbsolute", "(", "$", "path", ")", "{", "$", "firstChar", "=", "substr", "(", "$", "path", ",", "0", ",", "1", ")", ";", "if", "(", "'/'", "===", "$", "firstChar", "||", "'\\\\'", "===", "$", "firstChar", ")", "{", "return",...
Tells if the given path is absolute. @param string $path @return boolean
[ "Tells", "if", "the", "given", "path", "is", "absolute", "." ]
db6c8f040af38dfb01066e382645aff6c72530fa
https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Adapters/Local.php#L39-L51
train
samurai-fw/samurai
src/Samurai/Component/Core/Accessor.php
Accessor.hasProperty
public function hasProperty($name) { static $vars = null; if (! $vars) { $vars = get_object_vars($this); } return array_key_exists($name, $vars); }
php
public function hasProperty($name) { static $vars = null; if (! $vars) { $vars = get_object_vars($this); } return array_key_exists($name, $vars); }
[ "public", "function", "hasProperty", "(", "$", "name", ")", "{", "static", "$", "vars", "=", "null", ";", "if", "(", "!", "$", "vars", ")", "{", "$", "vars", "=", "get_object_vars", "(", "$", "this", ")", ";", "}", "return", "array_key_exists", "(", ...
has property ? @access public @param string $name @return boolean
[ "has", "property", "?" ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Core/Accessor.php#L143-L151
train
phn-io/compilation
src/Phn/Compilation/Debug.php
Debug.dumpTree
private static function dumpTree(NodeInterface $node, $verbose, $indent = 0) { list($attributes, $nodes) = self::extract($node); $dump = get_class($node); if ($attributes) { $dump .= ' ('; $dump .= implode(', ', array_map( function ($key, $value) use ($verbose) { return ($verbose ? sprintf('%s = ', $key) : '').self::stringify($value); }, array_keys($attributes), array_values($attributes) )); $dump .= ')'; } if ($nodes) { $dump .= ' {'.PHP_EOL; foreach ($nodes as $key => $node) { $dump .= str_repeat(' ', $indent + 1); if ($verbose && is_string($key)) { $dump .= sprintf('%s = ', $key); } if (is_array($node)) { $dump .= '['.PHP_EOL; foreach ($node as $item) { $dump .= str_repeat(' ', $indent + 2).self::dumpTree($item, $verbose, $indent + 2).PHP_EOL; } $dump .= str_repeat(' ', $indent + 1).']'.PHP_EOL; } else { $dump .= self::dumpTree($node, $verbose, $indent + 1).PHP_EOL; } } $dump .= str_repeat(' ', $indent).'}'; } return $dump; }
php
private static function dumpTree(NodeInterface $node, $verbose, $indent = 0) { list($attributes, $nodes) = self::extract($node); $dump = get_class($node); if ($attributes) { $dump .= ' ('; $dump .= implode(', ', array_map( function ($key, $value) use ($verbose) { return ($verbose ? sprintf('%s = ', $key) : '').self::stringify($value); }, array_keys($attributes), array_values($attributes) )); $dump .= ')'; } if ($nodes) { $dump .= ' {'.PHP_EOL; foreach ($nodes as $key => $node) { $dump .= str_repeat(' ', $indent + 1); if ($verbose && is_string($key)) { $dump .= sprintf('%s = ', $key); } if (is_array($node)) { $dump .= '['.PHP_EOL; foreach ($node as $item) { $dump .= str_repeat(' ', $indent + 2).self::dumpTree($item, $verbose, $indent + 2).PHP_EOL; } $dump .= str_repeat(' ', $indent + 1).']'.PHP_EOL; } else { $dump .= self::dumpTree($node, $verbose, $indent + 1).PHP_EOL; } } $dump .= str_repeat(' ', $indent).'}'; } return $dump; }
[ "private", "static", "function", "dumpTree", "(", "NodeInterface", "$", "node", ",", "$", "verbose", ",", "$", "indent", "=", "0", ")", "{", "list", "(", "$", "attributes", ",", "$", "nodes", ")", "=", "self", "::", "extract", "(", "$", "node", ")", ...
Dumps the node and its children as a pretty printed string representation. @param NodeInterface $node The root node to dump. @param bool $verbose The dump will be more verbose if this flag is set to `true`. @param int $indent The indentation level to apply. @return string The dump of the node and its children.
[ "Dumps", "the", "node", "and", "its", "children", "as", "a", "pretty", "printed", "string", "representation", "." ]
202e1816cc0039c08ad7ab3eb914e91e51d77320
https://github.com/phn-io/compilation/blob/202e1816cc0039c08ad7ab3eb914e91e51d77320/src/Phn/Compilation/Debug.php#L59-L106
train
phn-io/compilation
src/Phn/Compilation/Debug.php
Debug.extract
private static function extract(NodeInterface $node) { $attributes = []; $nodes = []; foreach (self::extractProperties($node) as $name => $value) { if (is_array($value)) { foreach ($value as $item) { if ($item instanceof NodeInterface) { $nodes[$name][] = $item; } else { $attributes[$name][] = $item; } } } else { if ($value instanceof NodeInterface) { $nodes[$name] = $value; } else { $attributes[$name] = $value; } } } return [$attributes, $nodes]; }
php
private static function extract(NodeInterface $node) { $attributes = []; $nodes = []; foreach (self::extractProperties($node) as $name => $value) { if (is_array($value)) { foreach ($value as $item) { if ($item instanceof NodeInterface) { $nodes[$name][] = $item; } else { $attributes[$name][] = $item; } } } else { if ($value instanceof NodeInterface) { $nodes[$name] = $value; } else { $attributes[$name] = $value; } } } return [$attributes, $nodes]; }
[ "private", "static", "function", "extract", "(", "NodeInterface", "$", "node", ")", "{", "$", "attributes", "=", "[", "]", ";", "$", "nodes", "=", "[", "]", ";", "foreach", "(", "self", "::", "extractProperties", "(", "$", "node", ")", "as", "$", "na...
Extracts the properties of the given node. @param NodeInterface $node The node to use for the extraction. @return array An array with two indexes: the attributes and the children nodes.
[ "Extracts", "the", "properties", "of", "the", "given", "node", "." ]
202e1816cc0039c08ad7ab3eb914e91e51d77320
https://github.com/phn-io/compilation/blob/202e1816cc0039c08ad7ab3eb914e91e51d77320/src/Phn/Compilation/Debug.php#L115-L139
train
phn-io/compilation
src/Phn/Compilation/Debug.php
Debug.extractProperties
private static function extractProperties(NodeInterface $node) { $class = new \ReflectionClass($node); foreach ($class->getProperties() as $property) { if (!$property->isPublic()) { $property->setAccessible(true); } $name = $property->getName(); $value = $property->getValue($node); yield $name => $value; if (!$property->isPublic()) { $property->setAccessible(false); } } }
php
private static function extractProperties(NodeInterface $node) { $class = new \ReflectionClass($node); foreach ($class->getProperties() as $property) { if (!$property->isPublic()) { $property->setAccessible(true); } $name = $property->getName(); $value = $property->getValue($node); yield $name => $value; if (!$property->isPublic()) { $property->setAccessible(false); } } }
[ "private", "static", "function", "extractProperties", "(", "NodeInterface", "$", "node", ")", "{", "$", "class", "=", "new", "\\", "ReflectionClass", "(", "$", "node", ")", ";", "foreach", "(", "$", "class", "->", "getProperties", "(", ")", "as", "$", "p...
Provides a generator that share the properties of the given node. @param NodeInterface $node The node to use for the extraction. @return \Generator A key value tuple.
[ "Provides", "a", "generator", "that", "share", "the", "properties", "of", "the", "given", "node", "." ]
202e1816cc0039c08ad7ab3eb914e91e51d77320
https://github.com/phn-io/compilation/blob/202e1816cc0039c08ad7ab3eb914e91e51d77320/src/Phn/Compilation/Debug.php#L148-L166
train
phn-io/compilation
src/Phn/Compilation/Debug.php
Debug.stringify
private static function stringify($value) { if (is_string($value)) { return sprintf('"%s"', preg_replace('/\n/', '\n', $value)); } if (is_bool($value)) { return $value ? 'true' : 'false'; } if (is_null($value)) { return 'null'; } if (is_array($value)) { return sprintf('[%s]', implode(', ', array_map( function ($value) { return self::stringify($value); }, $value ))); } return (string) $value; }
php
private static function stringify($value) { if (is_string($value)) { return sprintf('"%s"', preg_replace('/\n/', '\n', $value)); } if (is_bool($value)) { return $value ? 'true' : 'false'; } if (is_null($value)) { return 'null'; } if (is_array($value)) { return sprintf('[%s]', implode(', ', array_map( function ($value) { return self::stringify($value); }, $value ))); } return (string) $value; }
[ "private", "static", "function", "stringify", "(", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "return", "sprintf", "(", "'\"%s\"'", ",", "preg_replace", "(", "'/\\n/'", ",", "'\\n'", ",", "$", "value", ")", ")", ...
Stringify the given value. It can handles strings, booleans, null values and arrays. The other types would be casted into string. @param string $value The value to stringify. @return string The string representation of the given value.
[ "Stringify", "the", "given", "value", ".", "It", "can", "handles", "strings", "booleans", "null", "values", "and", "arrays", ".", "The", "other", "types", "would", "be", "casted", "into", "string", "." ]
202e1816cc0039c08ad7ab3eb914e91e51d77320
https://github.com/phn-io/compilation/blob/202e1816cc0039c08ad7ab3eb914e91e51d77320/src/Phn/Compilation/Debug.php#L176-L200
train
jasand-pereza/addmany
src/AddMany.php
AddMany.removeAbandonedPosts
public static function removeAbandonedPosts() { $sub_posts = \SubPost::getWhere(array('post_parent' => 0)); foreach($sub_posts as $sp) { wp_delete_post($sp->ID, true); } }
php
public static function removeAbandonedPosts() { $sub_posts = \SubPost::getWhere(array('post_parent' => 0)); foreach($sub_posts as $sp) { wp_delete_post($sp->ID, true); } }
[ "public", "static", "function", "removeAbandonedPosts", "(", ")", "{", "$", "sub_posts", "=", "\\", "SubPost", "::", "getWhere", "(", "array", "(", "'post_parent'", "=>", "0", ")", ")", ";", "foreach", "(", "$", "sub_posts", "as", "$", "sp", ")", "{", ...
without hitting the publish or update button
[ "without", "hitting", "the", "publish", "or", "update", "button" ]
309fb1590e669983e6f13b94ab8fd2166e43f188
https://github.com/jasand-pereza/addmany/blob/309fb1590e669983e6f13b94ab8fd2166e43f188/src/AddMany.php#L190-L195
train
alfredoem/ragnarok
app/Ragnarok/Soul/AuthRagnarok.php
AuthRagnarok.retrieve
public function retrieve($name) { $this->userRagnarok = Session::get($this->getName()); if (property_exists($this->userRagnarok, $name)) { return $this->userRagnarok->$name; } return null; }
php
public function retrieve($name) { $this->userRagnarok = Session::get($this->getName()); if (property_exists($this->userRagnarok, $name)) { return $this->userRagnarok->$name; } return null; }
[ "public", "function", "retrieve", "(", "$", "name", ")", "{", "$", "this", "->", "userRagnarok", "=", "Session", "::", "get", "(", "$", "this", "->", "getName", "(", ")", ")", ";", "if", "(", "property_exists", "(", "$", "this", "->", "userRagnarok", ...
Get User Session Object attribute @param $name @return string|null
[ "Get", "User", "Session", "Object", "attribute" ]
e7de18cbe7a64e6ce480093d9d98d64078d35dff
https://github.com/alfredoem/ragnarok/blob/e7de18cbe7a64e6ce480093d9d98d64078d35dff/app/Ragnarok/Soul/AuthRagnarok.php#L24-L33
train
alfredoem/ragnarok
app/Ragnarok/Soul/AuthRagnarok.php
AuthRagnarok.make
public function make($user) { $RagnarokUser = new SecUser(); $this->userRagnarok = $RagnarokUser->populate($user); Session::put($this->getName(), $this->userRagnarok); return $this->userRagnarok; }
php
public function make($user) { $RagnarokUser = new SecUser(); $this->userRagnarok = $RagnarokUser->populate($user); Session::put($this->getName(), $this->userRagnarok); return $this->userRagnarok; }
[ "public", "function", "make", "(", "$", "user", ")", "{", "$", "RagnarokUser", "=", "new", "SecUser", "(", ")", ";", "$", "this", "->", "userRagnarok", "=", "$", "RagnarokUser", "->", "populate", "(", "$", "user", ")", ";", "Session", "::", "put", "(...
Make User Session Object @return \Alfredoem\Ragnarok\SecUsers\SecUser
[ "Make", "User", "Session", "Object" ]
e7de18cbe7a64e6ce480093d9d98d64078d35dff
https://github.com/alfredoem/ragnarok/blob/e7de18cbe7a64e6ce480093d9d98d64078d35dff/app/Ragnarok/Soul/AuthRagnarok.php#L48-L54
train
alfredoem/ragnarok
app/Ragnarok/Soul/AuthRagnarok.php
AuthRagnarok.instance
public function instance($data) { $RagnarokUser = new SecUser(); $this->userRagnarok = $RagnarokUser->populate($data); return $this->userRagnarok; }
php
public function instance($data) { $RagnarokUser = new SecUser(); $this->userRagnarok = $RagnarokUser->populate($data); return $this->userRagnarok; }
[ "public", "function", "instance", "(", "$", "data", ")", "{", "$", "RagnarokUser", "=", "new", "SecUser", "(", ")", ";", "$", "this", "->", "userRagnarok", "=", "$", "RagnarokUser", "->", "populate", "(", "$", "data", ")", ";", "return", "$", "this", ...
Get a new instance of the User @param $data @return $this
[ "Get", "a", "new", "instance", "of", "the", "User" ]
e7de18cbe7a64e6ce480093d9d98d64078d35dff
https://github.com/alfredoem/ragnarok/blob/e7de18cbe7a64e6ce480093d9d98d64078d35dff/app/Ragnarok/Soul/AuthRagnarok.php#L61-L66
train
Sowapps/orpheus-inputcontroller
src/InputController/InputRequest.php
InputRequest.process
public function process() { $route = $this->findFirstMatchingRoute(); if( !$route ) { // Not found, look for an alternative (with /) $route = $this->findFirstMatchingRoute(true); if( $route ) { // Alternative found, try to redirect to this one $r = $this->redirect($route); if( $r ) { // Redirect return $r; } // Unable to redirect, throw not found $route = null; } } return $this->processRoute($route); }
php
public function process() { $route = $this->findFirstMatchingRoute(); if( !$route ) { // Not found, look for an alternative (with /) $route = $this->findFirstMatchingRoute(true); if( $route ) { // Alternative found, try to redirect to this one $r = $this->redirect($route); if( $r ) { // Redirect return $r; } // Unable to redirect, throw not found $route = null; } } return $this->processRoute($route); }
[ "public", "function", "process", "(", ")", "{", "$", "route", "=", "$", "this", "->", "findFirstMatchingRoute", "(", ")", ";", "if", "(", "!", "$", "route", ")", "{", "// Not found, look for an alternative (with /)", "$", "route", "=", "$", "this", "->", "...
Process the request by finding a route and processing it @return \Orpheus\InputController\OutputResponse
[ "Process", "the", "request", "by", "finding", "a", "route", "and", "processing", "it" ]
91f848a42ac02ae4009ffb3e9a9b4e8c0731455e
https://github.com/Sowapps/orpheus-inputcontroller/blob/91f848a42ac02ae4009ffb3e9a9b4e8c0731455e/src/InputController/InputRequest.php#L93-L110
train
Sowapps/orpheus-inputcontroller
src/InputController/InputRequest.php
InputRequest.processRoute
public function processRoute($route) { if( !$route ) { throw new NotFoundException('No route matches the current request '.$this); } $this->setRoute($route); return $this->route->run($this); }
php
public function processRoute($route) { if( !$route ) { throw new NotFoundException('No route matches the current request '.$this); } $this->setRoute($route); return $this->route->run($this); }
[ "public", "function", "processRoute", "(", "$", "route", ")", "{", "if", "(", "!", "$", "route", ")", "{", "throw", "new", "NotFoundException", "(", "'No route matches the current request '", ".", "$", "this", ")", ";", "}", "$", "this", "->", "setRoute", ...
Process the given route @param ControllerRoute $route @throws NotFoundException @return \Orpheus\InputController\OutputResponse
[ "Process", "the", "given", "route" ]
91f848a42ac02ae4009ffb3e9a9b4e8c0731455e
https://github.com/Sowapps/orpheus-inputcontroller/blob/91f848a42ac02ae4009ffb3e9a9b4e8c0731455e/src/InputController/InputRequest.php#L119-L125
train
webriq/core
module/Image/src/Grid/Image/Model/Paragraph/Structure/Image.php
Image.setWidth
public function setWidth( $width ) { $this->width = empty( $width ) ? null : (int) $width; return $this; }
php
public function setWidth( $width ) { $this->width = empty( $width ) ? null : (int) $width; return $this; }
[ "public", "function", "setWidth", "(", "$", "width", ")", "{", "$", "this", "->", "width", "=", "empty", "(", "$", "width", ")", "?", "null", ":", "(", "int", ")", "$", "width", ";", "return", "$", "this", ";", "}" ]
Set width attribute @param int $width @return \Image\Model\Paragraph\Structure\Image
[ "Set", "width", "attribute" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Image/src/Grid/Image/Model/Paragraph/Structure/Image.php#L138-L142
train
webriq/core
module/Image/src/Grid/Image/Model/Paragraph/Structure/Image.php
Image.setHeight
public function setHeight( $height ) { $this->height = empty( $height ) ? null : (int) $height; return $this; }
php
public function setHeight( $height ) { $this->height = empty( $height ) ? null : (int) $height; return $this; }
[ "public", "function", "setHeight", "(", "$", "height", ")", "{", "$", "this", "->", "height", "=", "empty", "(", "$", "height", ")", "?", "null", ":", "(", "int", ")", "$", "height", ";", "return", "$", "this", ";", "}" ]
Set height attribute @param int $height @return \Image\Model\Paragraph\Structure\Image
[ "Set", "height", "attribute" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Image/src/Grid/Image/Model/Paragraph/Structure/Image.php#L160-L164
train
phossa2/libs
src/Phossa2/Cache/Extension/Encrypt.php
Encrypt.processValue
protected function processValue(callable $func, CacheItem $item) { $item->setStrVal($func($item->getStrVal())); return true; }
php
protected function processValue(callable $func, CacheItem $item) { $item->setStrVal($func($item->getStrVal())); return true; }
[ "protected", "function", "processValue", "(", "callable", "$", "func", ",", "CacheItem", "$", "item", ")", "{", "$", "item", "->", "setStrVal", "(", "$", "func", "(", "$", "item", "->", "getStrVal", "(", ")", ")", ")", ";", "return", "true", ";", "}"...
Encrypt or decrypt @param callable $func @param CacheItem $item @return bool @access protected
[ "Encrypt", "or", "decrypt" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Cache/Extension/Encrypt.php#L127-L131
train
belgattitude/soluble-spreadsheet
src/Soluble/Spreadsheet/Library/LibXL.php
LibXL.getExcelBook
public function getExcelBook($file_format = self::FILE_FORMAT_XLSX, $locale = 'UTF-8') { //@codeCoverageIgnoreStart if (!extension_loaded('excel')) { throw new Exception\RuntimeException(__METHOD__ . ' LibXL requires excel extension (https://github.com/iliaal/php_excel) and http://libxl.com/.'); } //@codeCoverageIgnoreEnd if (!$this->isSupportedFormat($file_format)) { throw new Exception\InvalidArgumentException(__METHOD__ . " Unsupported file format '$file_format'."); } $license = $this->getLicense(); $license_name = $license['name']; $license_key = $license['key']; $excel2007 = true; switch ($file_format) { case self::FILE_FORMAT_XLS: $excel2007 = false; break; } $book = new ExcelBook($license_name, $license_key, $excel2007); if ($locale !== null) { $book->setLocale($locale); } return $book; }
php
public function getExcelBook($file_format = self::FILE_FORMAT_XLSX, $locale = 'UTF-8') { //@codeCoverageIgnoreStart if (!extension_loaded('excel')) { throw new Exception\RuntimeException(__METHOD__ . ' LibXL requires excel extension (https://github.com/iliaal/php_excel) and http://libxl.com/.'); } //@codeCoverageIgnoreEnd if (!$this->isSupportedFormat($file_format)) { throw new Exception\InvalidArgumentException(__METHOD__ . " Unsupported file format '$file_format'."); } $license = $this->getLicense(); $license_name = $license['name']; $license_key = $license['key']; $excel2007 = true; switch ($file_format) { case self::FILE_FORMAT_XLS: $excel2007 = false; break; } $book = new ExcelBook($license_name, $license_key, $excel2007); if ($locale !== null) { $book->setLocale($locale); } return $book; }
[ "public", "function", "getExcelBook", "(", "$", "file_format", "=", "self", "::", "FILE_FORMAT_XLSX", ",", "$", "locale", "=", "'UTF-8'", ")", "{", "//@codeCoverageIgnoreStart", "if", "(", "!", "extension_loaded", "(", "'excel'", ")", ")", "{", "throw", "new",...
Return an empty ExcelBook instance @throws Exception\RuntimeException if no excel extension is found @throws Exception\InvalidArgumentException if unsupported format @param string $file_format by default xlsx, see constants FILE_FORMAT_* @param string $locale by default utf-8 @return ExcelBook
[ "Return", "an", "empty", "ExcelBook", "instance" ]
08df46c7199404343433a59a664d4e2c2afa10fb
https://github.com/belgattitude/soluble-spreadsheet/blob/08df46c7199404343433a59a664d4e2c2afa10fb/src/Soluble/Spreadsheet/Library/LibXL.php#L55-L81
train
belgattitude/soluble-spreadsheet
src/Soluble/Spreadsheet/Library/LibXL.php
LibXL.isSupportedFormat
public static function isSupportedFormat($format) { if (!is_string($format)) { throw new Exception\InvalidArgumentException(__METHOD__ . " file_format must be a string"); } return in_array((string) $format, self::$supportedFormats); }
php
public static function isSupportedFormat($format) { if (!is_string($format)) { throw new Exception\InvalidArgumentException(__METHOD__ . " file_format must be a string"); } return in_array((string) $format, self::$supportedFormats); }
[ "public", "static", "function", "isSupportedFormat", "(", "$", "format", ")", "{", "if", "(", "!", "is_string", "(", "$", "format", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "__METHOD__", ".", "\" file_format must be a st...
Check whether the format is supported @throws Exception\InvalidArgumentException @param string $format @return boolean
[ "Check", "whether", "the", "format", "is", "supported" ]
08df46c7199404343433a59a664d4e2c2afa10fb
https://github.com/belgattitude/soluble-spreadsheet/blob/08df46c7199404343433a59a664d4e2c2afa10fb/src/Soluble/Spreadsheet/Library/LibXL.php#L103-L109
train
belgattitude/soluble-spreadsheet
src/Soluble/Spreadsheet/Library/LibXL.php
LibXL.setDefaultLicense
public static function setDefaultLicense(array $license) { if (!array_key_exists('name', $license) || !array_key_exists('key', $license)) { throw new Exception\InvalidArgumentException(__METHOD__ . " In order to set a default libxl license you must provide an associative array with 'name' and 'key' set."); } self::$default_license = $license; }
php
public static function setDefaultLicense(array $license) { if (!array_key_exists('name', $license) || !array_key_exists('key', $license)) { throw new Exception\InvalidArgumentException(__METHOD__ . " In order to set a default libxl license you must provide an associative array with 'name' and 'key' set."); } self::$default_license = $license; }
[ "public", "static", "function", "setDefaultLicense", "(", "array", "$", "license", ")", "{", "if", "(", "!", "array_key_exists", "(", "'name'", ",", "$", "license", ")", "||", "!", "array_key_exists", "(", "'key'", ",", "$", "license", ")", ")", "{", "th...
Set default license information @throws Exception\InvalidArgumentException @param array $license associative array with 'name' and 'key'
[ "Set", "default", "license", "information" ]
08df46c7199404343433a59a664d4e2c2afa10fb
https://github.com/belgattitude/soluble-spreadsheet/blob/08df46c7199404343433a59a664d4e2c2afa10fb/src/Soluble/Spreadsheet/Library/LibXL.php#L141-L148
train
jamiehannaford/php-opencloud-zf2
src/Helper/CloudFilesHelper.php
CloudFilesHelper.getContainer
protected function getContainer($name) { if (!isset($this->containers[$name])) { $this->createContainer($name); } return $this->containers[$name]; }
php
protected function getContainer($name) { if (!isset($this->containers[$name])) { $this->createContainer($name); } return $this->containers[$name]; }
[ "protected", "function", "getContainer", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "containers", "[", "$", "name", "]", ")", ")", "{", "$", "this", "->", "createContainer", "(", "$", "name", ")", ";", "}", "return...
Return a container wrapper based on its name, saving to cache if necessary. @param $name Container name @return \Zend\Zf2\Helper\CloudFiles\Container @throws \Zend\View\Exception\InvalidArgumentException
[ "Return", "a", "container", "wrapper", "based", "on", "its", "name", "saving", "to", "cache", "if", "necessary", "." ]
74140adaffc0b46d7bbe1d7b3441c61f2cf6a656
https://github.com/jamiehannaford/php-opencloud-zf2/blob/74140adaffc0b46d7bbe1d7b3441c61f2cf6a656/src/Helper/CloudFilesHelper.php#L56-L63
train
jamiehannaford/php-opencloud-zf2
src/Helper/CloudFilesHelper.php
CloudFilesHelper.createContainer
protected function createContainer($name) { $this->containers[$name] = new Container($this->getView(), $this->service, $name); }
php
protected function createContainer($name) { $this->containers[$name] = new Container($this->getView(), $this->service, $name); }
[ "protected", "function", "createContainer", "(", "$", "name", ")", "{", "$", "this", "->", "containers", "[", "$", "name", "]", "=", "new", "Container", "(", "$", "this", "->", "getView", "(", ")", ",", "$", "this", "->", "service", ",", "$", "name",...
Create a new container wrapper and save it to cache @param $name Container name
[ "Create", "a", "new", "container", "wrapper", "and", "save", "it", "to", "cache" ]
74140adaffc0b46d7bbe1d7b3441c61f2cf6a656
https://github.com/jamiehannaford/php-opencloud-zf2/blob/74140adaffc0b46d7bbe1d7b3441c61f2cf6a656/src/Helper/CloudFilesHelper.php#L70-L73
train
samurai-fw/samurai
src/Onikiri/Transaction.php
Transaction.rollbackWithoutThrow
public function rollbackWithoutThrow() { if (! $this->isValid()) return; foreach ($this->getConnections() as $connection) { $connection->rollback(); } $this->_depth = 0; }
php
public function rollbackWithoutThrow() { if (! $this->isValid()) return; foreach ($this->getConnections() as $connection) { $connection->rollback(); } $this->_depth = 0; }
[ "public", "function", "rollbackWithoutThrow", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isValid", "(", ")", ")", "return", ";", "foreach", "(", "$", "this", "->", "getConnections", "(", ")", "as", "$", "connection", ")", "{", "$", "connection"...
rollback transaction without throw
[ "rollback", "transaction", "without", "throw" ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Onikiri/Transaction.php#L138-L147
train
RowlandOti/ooglee-core
src/OoGlee/Infrastructure/Presenter/Eloquent/EloquentPresenter.php
EloquentPresenter.createdAtDatetime
public function createdAtDatetime() { return $this->entity->created_at->setTimezone($this->config->get('config.timezone')) ->format($this->config->get('config.date_format') . ' ' . $this->config->get('config.time_format')); }
php
public function createdAtDatetime() { return $this->entity->created_at->setTimezone($this->config->get('config.timezone')) ->format($this->config->get('config.date_format') . ' ' . $this->config->get('config.time_format')); }
[ "public", "function", "createdAtDatetime", "(", ")", "{", "return", "$", "this", "->", "entity", "->", "created_at", "->", "setTimezone", "(", "$", "this", "->", "config", "->", "get", "(", "'config.timezone'", ")", ")", "->", "format", "(", "$", "this", ...
Return the datetime string for created at. @return string
[ "Return", "the", "datetime", "string", "for", "created", "at", "." ]
6cd8a8e58e37749e1c58e99063ea72c9d37a98bc
https://github.com/RowlandOti/ooglee-core/blob/6cd8a8e58e37749e1c58e99063ea72c9d37a98bc/src/OoGlee/Infrastructure/Presenter/Eloquent/EloquentPresenter.php#L53-L57
train
RowlandOti/ooglee-core
src/OoGlee/Infrastructure/Presenter/Eloquent/EloquentPresenter.php
EloquentPresenter.updatedAtDate
public function updatedAtDate() { return $this->entity->updated_at->setTimezone($this->config->get('config.timezone')) ->format($this->config->get('config.date_format')); }
php
public function updatedAtDate() { return $this->entity->updated_at->setTimezone($this->config->get('config.timezone')) ->format($this->config->get('config.date_format')); }
[ "public", "function", "updatedAtDate", "(", ")", "{", "return", "$", "this", "->", "entity", "->", "updated_at", "->", "setTimezone", "(", "$", "this", "->", "config", "->", "get", "(", "'config.timezone'", ")", ")", "->", "format", "(", "$", "this", "->...
Return the date string for updated at. @return string
[ "Return", "the", "date", "string", "for", "updated", "at", "." ]
6cd8a8e58e37749e1c58e99063ea72c9d37a98bc
https://github.com/RowlandOti/ooglee-core/blob/6cd8a8e58e37749e1c58e99063ea72c9d37a98bc/src/OoGlee/Infrastructure/Presenter/Eloquent/EloquentPresenter.php#L64-L68
train
RowlandOti/ooglee-core
src/OoGlee/Infrastructure/Presenter/Eloquent/EloquentPresenter.php
EloquentPresenter.updatedAtDatetime
public function updatedAtDatetime() { return $this->entity->updated_at->setTimezone($this->config->get('config.timezone')) ->format($this->config->get('config.date_format') . ' ' . $this->config->get('config.time_format')); }
php
public function updatedAtDatetime() { return $this->entity->updated_at->setTimezone($this->config->get('config.timezone')) ->format($this->config->get('config.date_format') . ' ' . $this->config->get('config.time_format')); }
[ "public", "function", "updatedAtDatetime", "(", ")", "{", "return", "$", "this", "->", "entity", "->", "updated_at", "->", "setTimezone", "(", "$", "this", "->", "config", "->", "get", "(", "'config.timezone'", ")", ")", "->", "format", "(", "$", "this", ...
Return the datetime string for updated at. @return string
[ "Return", "the", "datetime", "string", "for", "updated", "at", "." ]
6cd8a8e58e37749e1c58e99063ea72c9d37a98bc
https://github.com/RowlandOti/ooglee-core/blob/6cd8a8e58e37749e1c58e99063ea72c9d37a98bc/src/OoGlee/Infrastructure/Presenter/Eloquent/EloquentPresenter.php#L75-L79
train
beheh/sulphur
src/Response.php
Response.where
public function where($field, $section = 'Reference') { // default to reference if($section === null) { $section = 'Reference'; } // array_values reindexes the array here, otherwise we have gaps from non-matching array keys return new FilterableList(array_values(array_filter($this->sections, function(Section $val) use ($section) { // only return matching root sections return $val->getHeading() == $section; })), $field); }
php
public function where($field, $section = 'Reference') { // default to reference if($section === null) { $section = 'Reference'; } // array_values reindexes the array here, otherwise we have gaps from non-matching array keys return new FilterableList(array_values(array_filter($this->sections, function(Section $val) use ($section) { // only return matching root sections return $val->getHeading() == $section; })), $field); }
[ "public", "function", "where", "(", "$", "field", ",", "$", "section", "=", "'Reference'", ")", "{", "// default to reference", "if", "(", "$", "section", "===", "null", ")", "{", "$", "section", "=", "'Reference'", ";", "}", "// array_values reindexes the arr...
Sets the field for the first filter. @param string $field the field to filter @return FilterableList
[ "Sets", "the", "field", "for", "the", "first", "filter", "." ]
d608b40d6cf26f12476d992276ee9a0aa455bd55
https://github.com/beheh/sulphur/blob/d608b40d6cf26f12476d992276ee9a0aa455bd55/src/Response.php#L28-L38
train
railsphp/framework
src/Rails/Toolbox/ArrayTools.php
ArrayTools.flatten
public static function flatten(array $arr) { $flat = []; foreach ($arr as $v) { if (is_array($v)) { $flat = array_merge($flat, self::flatten($v)); } else { $flat[] = $v; } } return $flat; }
php
public static function flatten(array $arr) { $flat = []; foreach ($arr as $v) { if (is_array($v)) { $flat = array_merge($flat, self::flatten($v)); } else { $flat[] = $v; } } return $flat; }
[ "public", "static", "function", "flatten", "(", "array", "$", "arr", ")", "{", "$", "flat", "=", "[", "]", ";", "foreach", "(", "$", "arr", "as", "$", "v", ")", "{", "if", "(", "is_array", "(", "$", "v", ")", ")", "{", "$", "flat", "=", "arra...
Flattens an array.
[ "Flattens", "an", "array", "." ]
2ac9d3e493035dcc68f3c3812423327127327cd5
https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/Toolbox/ArrayTools.php#L9-L20
train
railsphp/framework
src/Rails/Toolbox/ArrayTools.php
ArrayTools.isIndexed
public static function isIndexed(array $array) { $i = 0; foreach (array_keys($array) as $k) { if ($k !== $i) { return false; } $i++; } return true; }
php
public static function isIndexed(array $array) { $i = 0; foreach (array_keys($array) as $k) { if ($k !== $i) { return false; } $i++; } return true; }
[ "public", "static", "function", "isIndexed", "(", "array", "$", "array", ")", "{", "$", "i", "=", "0", ";", "foreach", "(", "array_keys", "(", "$", "array", ")", "as", "$", "k", ")", "{", "if", "(", "$", "k", "!==", "$", "i", ")", "{", "return"...
Checks if an array is indexed.
[ "Checks", "if", "an", "array", "is", "indexed", "." ]
2ac9d3e493035dcc68f3c3812423327127327cd5
https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/Toolbox/ArrayTools.php#L25-L35
train
ripaclub/aclman
library/Service/ServiceAbstract.php
ServiceAbstract.addRole
public function addRole($role, $parents = null) { $this->getAcl()->addRole($role, $parents); return $this; }
php
public function addRole($role, $parents = null) { $this->getAcl()->addRole($role, $parents); return $this; }
[ "public", "function", "addRole", "(", "$", "role", ",", "$", "parents", "=", "null", ")", "{", "$", "this", "->", "getAcl", "(", ")", "->", "addRole", "(", "$", "role", ",", "$", "parents", ")", ";", "return", "$", "this", ";", "}" ]
Add roles from storage @param string|RoleInterface $role @param string|array|RoleInterface $parents @return $this
[ "Add", "roles", "from", "storage" ]
ca7c65fdb3291654f293829c70ced9fb2e1566f8
https://github.com/ripaclub/aclman/blob/ca7c65fdb3291654f293829c70ced9fb2e1566f8/library/Service/ServiceAbstract.php#L51-L55
train
fsi-open/metadata
lib/FSi/Component/Metadata/MetadataFactory.php
MetadataFactory.getClassMetadata
public function getClassMetadata($class) { $class = ltrim($class, '\\'); $metadataIndex = $this->getCacheId($class); if (isset($this->loadedMetadata[$metadataIndex])) { return $this->loadedMetadata[$metadataIndex]; } if (isset($this->cache)) { if (false !== ($metadata = $this->cache->fetch($metadataIndex))) { return $metadata; } } $metadata = new $this->metadataClassName($class); $parentClasses = array_reverse(class_parents($class)); foreach ($parentClasses as $parentClass) { $metadata->setClassName($parentClass); $this->driver->loadClassMetadata($metadata); } $metadata->setClassName($class); $this->driver->loadClassMetadata($metadata); if (isset($this->cache)) { $this->cache->save($metadataIndex, $metadata); } $this->loadedMetadata[$metadataIndex] = $metadata; return $metadata; }
php
public function getClassMetadata($class) { $class = ltrim($class, '\\'); $metadataIndex = $this->getCacheId($class); if (isset($this->loadedMetadata[$metadataIndex])) { return $this->loadedMetadata[$metadataIndex]; } if (isset($this->cache)) { if (false !== ($metadata = $this->cache->fetch($metadataIndex))) { return $metadata; } } $metadata = new $this->metadataClassName($class); $parentClasses = array_reverse(class_parents($class)); foreach ($parentClasses as $parentClass) { $metadata->setClassName($parentClass); $this->driver->loadClassMetadata($metadata); } $metadata->setClassName($class); $this->driver->loadClassMetadata($metadata); if (isset($this->cache)) { $this->cache->save($metadataIndex, $metadata); } $this->loadedMetadata[$metadataIndex] = $metadata; return $metadata; }
[ "public", "function", "getClassMetadata", "(", "$", "class", ")", "{", "$", "class", "=", "ltrim", "(", "$", "class", ",", "'\\\\'", ")", ";", "$", "metadataIndex", "=", "$", "this", "->", "getCacheId", "(", "$", "class", ")", ";", "if", "(", "isset"...
Returns class metadata read by the driver. This method calls itself recursively for each ancestor class @param string $class @return \FSi\Component\Metadata\ClassMetadataInterface
[ "Returns", "class", "metadata", "read", "by", "the", "driver", ".", "This", "method", "calls", "itself", "recursively", "for", "each", "ancestor", "class" ]
65c36bdab257d19d58e264b2b36bcf97a144075f
https://github.com/fsi-open/metadata/blob/65c36bdab257d19d58e264b2b36bcf97a144075f/lib/FSi/Component/Metadata/MetadataFactory.php#L89-L121
train
squire-assistant/console
Helper/QuestionHelper.php
QuestionHelper.setInputStream
public function setInputStream($stream) { @trigger_error(sprintf('The %s() method is deprecated since version 3.2 and will be removed in 4.0. Use %s::setStream() instead.', __METHOD__, StreamableInputInterface::class), E_USER_DEPRECATED); if (!is_resource($stream)) { throw new InvalidArgumentException('Input stream must be a valid resource.'); } $this->inputStream = $stream; }
php
public function setInputStream($stream) { @trigger_error(sprintf('The %s() method is deprecated since version 3.2 and will be removed in 4.0. Use %s::setStream() instead.', __METHOD__, StreamableInputInterface::class), E_USER_DEPRECATED); if (!is_resource($stream)) { throw new InvalidArgumentException('Input stream must be a valid resource.'); } $this->inputStream = $stream; }
[ "public", "function", "setInputStream", "(", "$", "stream", ")", "{", "@", "trigger_error", "(", "sprintf", "(", "'The %s() method is deprecated since version 3.2 and will be removed in 4.0. Use %s::setStream() instead.'", ",", "__METHOD__", ",", "StreamableInputInterface", "::",...
Sets the input stream to read from when interacting with the user. This is mainly useful for testing purpose. @deprecated since version 3.2, to be removed in 4.0. Use StreamableInputInterface::setStream() instead. @param resource $stream The input stream @throws InvalidArgumentException In case the stream is not a resource
[ "Sets", "the", "input", "stream", "to", "read", "from", "when", "interacting", "with", "the", "user", "." ]
9e16b975a3b9403af52e2d1b465a625e8936076c
https://github.com/squire-assistant/console/blob/9e16b975a3b9403af52e2d1b465a625e8936076c/Helper/QuestionHelper.php#L83-L92
train
squire-assistant/console
Helper/QuestionHelper.php
QuestionHelper.getInputStream
public function getInputStream() { if (0 === func_num_args() || func_get_arg(0)) { @trigger_error(sprintf('The %s() method is deprecated since version 3.2 and will be removed in 4.0. Use %s::getStream() instead.', __METHOD__, StreamableInputInterface::class), E_USER_DEPRECATED); } return $this->inputStream; }
php
public function getInputStream() { if (0 === func_num_args() || func_get_arg(0)) { @trigger_error(sprintf('The %s() method is deprecated since version 3.2 and will be removed in 4.0. Use %s::getStream() instead.', __METHOD__, StreamableInputInterface::class), E_USER_DEPRECATED); } return $this->inputStream; }
[ "public", "function", "getInputStream", "(", ")", "{", "if", "(", "0", "===", "func_num_args", "(", ")", "||", "func_get_arg", "(", "0", ")", ")", "{", "@", "trigger_error", "(", "sprintf", "(", "'The %s() method is deprecated since version 3.2 and will be removed i...
Returns the helper's input stream. @deprecated since version 3.2, to be removed in 4.0. Use StreamableInputInterface::getStream() instead. @return resource
[ "Returns", "the", "helper", "s", "input", "stream", "." ]
9e16b975a3b9403af52e2d1b465a625e8936076c
https://github.com/squire-assistant/console/blob/9e16b975a3b9403af52e2d1b465a625e8936076c/Helper/QuestionHelper.php#L102-L109
train
squire-assistant/console
Helper/QuestionHelper.php
QuestionHelper.getShell
private function getShell() { if (null !== self::$shell) { return self::$shell; } self::$shell = false; if (file_exists('/usr/bin/env')) { // handle other OSs with bash/zsh/ksh/csh if available to hide the answer $test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null"; foreach (array('bash', 'zsh', 'ksh', 'csh') as $sh) { if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) { self::$shell = $sh; break; } } } return self::$shell; }
php
private function getShell() { if (null !== self::$shell) { return self::$shell; } self::$shell = false; if (file_exists('/usr/bin/env')) { // handle other OSs with bash/zsh/ksh/csh if available to hide the answer $test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null"; foreach (array('bash', 'zsh', 'ksh', 'csh') as $sh) { if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) { self::$shell = $sh; break; } } } return self::$shell; }
[ "private", "function", "getShell", "(", ")", "{", "if", "(", "null", "!==", "self", "::", "$", "shell", ")", "{", "return", "self", "::", "$", "shell", ";", "}", "self", "::", "$", "shell", "=", "false", ";", "if", "(", "file_exists", "(", "'/usr/b...
Returns a valid unix shell. @return string|bool The valid shell name, false in case no valid shell is found
[ "Returns", "a", "valid", "unix", "shell", "." ]
9e16b975a3b9403af52e2d1b465a625e8936076c
https://github.com/squire-assistant/console/blob/9e16b975a3b9403af52e2d1b465a625e8936076c/Helper/QuestionHelper.php#L437-L457
train
AmericanCouncils/TranscodingBundle
Console/OutputSubscriber.php
OutputSubscriber.onMessage
public function onMessage(MessageEvent $e) { $formatter = $this->getFormatter(); $adapterKey = $e->getAdapter()->getKey(); $level = $e->getLevel(); $message = $e->getMessage(); $match = '/\r\n?/'; //check if the message has weird formatting before trying to format it (currently a hack to avoid segmentation faults) if (!preg_match($match, $message)) { $msg = sprintf( "%s (%s): %s", $formatter->formatBlock($adapterKey, 'info'), $formatter->formatBlock($level, 'comment'), $message ); } else { $msg = sprintf( "%s (%s): %s", $adapterKey, $level, preg_replace('/\r\n?/', '', $message) ); } $this->getOutput()->writeln($msg); }
php
public function onMessage(MessageEvent $e) { $formatter = $this->getFormatter(); $adapterKey = $e->getAdapter()->getKey(); $level = $e->getLevel(); $message = $e->getMessage(); $match = '/\r\n?/'; //check if the message has weird formatting before trying to format it (currently a hack to avoid segmentation faults) if (!preg_match($match, $message)) { $msg = sprintf( "%s (%s): %s", $formatter->formatBlock($adapterKey, 'info'), $formatter->formatBlock($level, 'comment'), $message ); } else { $msg = sprintf( "%s (%s): %s", $adapterKey, $level, preg_replace('/\r\n?/', '', $message) ); } $this->getOutput()->writeln($msg); }
[ "public", "function", "onMessage", "(", "MessageEvent", "$", "e", ")", "{", "$", "formatter", "=", "$", "this", "->", "getFormatter", "(", ")", ";", "$", "adapterKey", "=", "$", "e", "->", "getAdapter", "(", ")", "->", "getKey", "(", ")", ";", "$", ...
Write any messages received by an adapter
[ "Write", "any", "messages", "received", "by", "an", "adapter" ]
7131989ffc014221a9a89c6854c8e618eb4fa2e3
https://github.com/AmericanCouncils/TranscodingBundle/blob/7131989ffc014221a9a89c6854c8e618eb4fa2e3/Console/OutputSubscriber.php#L37-L64
train
AmericanCouncils/TranscodingBundle
Console/OutputSubscriber.php
OutputSubscriber.onTranscodeStart
public function onTranscodeStart(TranscodeEvent $e) { $inpath = $e->getInputPath(); $presetKey = $e->getPreset(); $formatter = $this->getFormatter(); $msg = sprintf( "Starting transcode of file %s with preset %s ...", $formatter->formatBlock($inpath, 'info'), $formatter->formatBlock($presetKey, 'info') ); $this->getOutput()->writeln($msg); $this->startTime = microtime(true); }
php
public function onTranscodeStart(TranscodeEvent $e) { $inpath = $e->getInputPath(); $presetKey = $e->getPreset(); $formatter = $this->getFormatter(); $msg = sprintf( "Starting transcode of file %s with preset %s ...", $formatter->formatBlock($inpath, 'info'), $formatter->formatBlock($presetKey, 'info') ); $this->getOutput()->writeln($msg); $this->startTime = microtime(true); }
[ "public", "function", "onTranscodeStart", "(", "TranscodeEvent", "$", "e", ")", "{", "$", "inpath", "=", "$", "e", "->", "getInputPath", "(", ")", ";", "$", "presetKey", "=", "$", "e", "->", "getPreset", "(", ")", ";", "$", "formatter", "=", "$", "th...
Write to output that a process has started.
[ "Write", "to", "output", "that", "a", "process", "has", "started", "." ]
7131989ffc014221a9a89c6854c8e618eb4fa2e3
https://github.com/AmericanCouncils/TranscodingBundle/blob/7131989ffc014221a9a89c6854c8e618eb4fa2e3/Console/OutputSubscriber.php#L69-L83
train
AmericanCouncils/TranscodingBundle
Console/OutputSubscriber.php
OutputSubscriber.onTranscodeComplete
public function onTranscodeComplete(TranscodeEvent $e) { $outpath = $e->getOutputPath(); $totalTime = microtime(true) - $this->startTime; $formatter = $this->getFormatter(); $msg = sprintf( "Transcode completed in %s seconds.", $formatter->formatBlock(round($totalTime, 4), 'info') ); $this->getOutput()->writeln($msg); $msg = sprintf( "Created new file %s", $formatter->formatBlock($outpath, 'info') ); $this->getOutput()->writeln($msg); }
php
public function onTranscodeComplete(TranscodeEvent $e) { $outpath = $e->getOutputPath(); $totalTime = microtime(true) - $this->startTime; $formatter = $this->getFormatter(); $msg = sprintf( "Transcode completed in %s seconds.", $formatter->formatBlock(round($totalTime, 4), 'info') ); $this->getOutput()->writeln($msg); $msg = sprintf( "Created new file %s", $formatter->formatBlock($outpath, 'info') ); $this->getOutput()->writeln($msg); }
[ "public", "function", "onTranscodeComplete", "(", "TranscodeEvent", "$", "e", ")", "{", "$", "outpath", "=", "$", "e", "->", "getOutputPath", "(", ")", ";", "$", "totalTime", "=", "microtime", "(", "true", ")", "-", "$", "this", "->", "startTime", ";", ...
Write to output that a process has completed.
[ "Write", "to", "output", "that", "a", "process", "has", "completed", "." ]
7131989ffc014221a9a89c6854c8e618eb4fa2e3
https://github.com/AmericanCouncils/TranscodingBundle/blob/7131989ffc014221a9a89c6854c8e618eb4fa2e3/Console/OutputSubscriber.php#L88-L105
train
AmericanCouncils/TranscodingBundle
Console/OutputSubscriber.php
OutputSubscriber.onTranscodeFailure
public function onTranscodeFailure(TranscodeEvent $e) { $inpath = $e->getInputPath(); $errorMsg = $e->getException()->getMessage(); $formatter = $this->getFormatter(); $msg = sprintf( "Transcode of %s failed! Message: %s", $formatter->formatBlock($inpath, 'info'), $formatter->formatBlock($errorMsg, 'error') ); $this->getOutput()->writeln($msg); }
php
public function onTranscodeFailure(TranscodeEvent $e) { $inpath = $e->getInputPath(); $errorMsg = $e->getException()->getMessage(); $formatter = $this->getFormatter(); $msg = sprintf( "Transcode of %s failed! Message: %s", $formatter->formatBlock($inpath, 'info'), $formatter->formatBlock($errorMsg, 'error') ); $this->getOutput()->writeln($msg); }
[ "public", "function", "onTranscodeFailure", "(", "TranscodeEvent", "$", "e", ")", "{", "$", "inpath", "=", "$", "e", "->", "getInputPath", "(", ")", ";", "$", "errorMsg", "=", "$", "e", "->", "getException", "(", ")", "->", "getMessage", "(", ")", ";",...
Write to output that a process has failed.
[ "Write", "to", "output", "that", "a", "process", "has", "failed", "." ]
7131989ffc014221a9a89c6854c8e618eb4fa2e3
https://github.com/AmericanCouncils/TranscodingBundle/blob/7131989ffc014221a9a89c6854c8e618eb4fa2e3/Console/OutputSubscriber.php#L110-L123
train
crater-framework/crater-php-framework
Migration.php
Migration.newMigration
public function newMigration($name) { $time = time(); $date = date("n/j/Y"); $fileName = "{$time}_migration.php"; if ($name) $fileName = "{$time}_{$name}.php"; $file = $this->storagePath . "/" . $fileName; $class = 'Migration_' . ((int)$time); $contents = array('<?php'); $contents[] = '/*'; $contents[] = " * {$name} migration file"; $contents[] = ' *'; $contents[] = ' * @author '; $contents[] = ' * @version 1.0'; $contents[] = " * @date $date"; $contents[] = ' */'; $contents[] = 'class ' . $class . ' extends \Core\Migration'; $contents[] = '{'; $contents[] = ''; $contents[] = " public function up()"; $contents[] = " {"; $contents[] = ""; $contents[] = " }"; $contents[] = ""; $contents[] = " public function down()"; $contents[] = " {"; $contents[] = ""; $contents[] = " }"; $contents[] = '}'; if (file_put_contents($file, implode("\n", $contents))) { echo 'Create ' . $file . "\n\r"; return $file; } return false; }
php
public function newMigration($name) { $time = time(); $date = date("n/j/Y"); $fileName = "{$time}_migration.php"; if ($name) $fileName = "{$time}_{$name}.php"; $file = $this->storagePath . "/" . $fileName; $class = 'Migration_' . ((int)$time); $contents = array('<?php'); $contents[] = '/*'; $contents[] = " * {$name} migration file"; $contents[] = ' *'; $contents[] = ' * @author '; $contents[] = ' * @version 1.0'; $contents[] = " * @date $date"; $contents[] = ' */'; $contents[] = 'class ' . $class . ' extends \Core\Migration'; $contents[] = '{'; $contents[] = ''; $contents[] = " public function up()"; $contents[] = " {"; $contents[] = ""; $contents[] = " }"; $contents[] = ""; $contents[] = " public function down()"; $contents[] = " {"; $contents[] = ""; $contents[] = " }"; $contents[] = '}'; if (file_put_contents($file, implode("\n", $contents))) { echo 'Create ' . $file . "\n\r"; return $file; } return false; }
[ "public", "function", "newMigration", "(", "$", "name", ")", "{", "$", "time", "=", "time", "(", ")", ";", "$", "date", "=", "date", "(", "\"n/j/Y\"", ")", ";", "$", "fileName", "=", "\"{$time}_migration.php\"", ";", "if", "(", "$", "name", ")", "$",...
Create new migration file @param string $name Name of migration file @return bool|string
[ "Create", "new", "migration", "file" ]
ff7a4f69f8ee7beb37adee348b67d1be84c51ff1
https://github.com/crater-framework/crater-php-framework/blob/ff7a4f69f8ee7beb37adee348b67d1be84c51ff1/Migration.php#L22-L59
train
crater-framework/crater-php-framework
Migration.php
Migration.createTable
public function createTable($name, $data) { $q = "CREATE TABLE {$name} ("; foreach ($data as $key => $v) { $q .= $key; if (isset($v['type'])) { $q .= " {$v['type']}"; if (isset($v['length'])) { $q .= "({$v['length']})"; } else { if ($v['type'] != 'int' && $v['type'] != 'datetime') { die ("Please set length for table: {$name} - column: {$key}"); } } if (isset($v['unsigned']) && $v['unsigned'] == true) { $q .= " UNSIGNED"; } if (!isset($v['null']) || $v['null'] == false) { $q .= " NOT NULL"; } if (isset($v['default'])) { if (is_string($v['default'])) { $v['default'] = "'{$v['default']}'"; } $q .= " DEFAULT {$v['default']}"; } if (isset($v['ai']) && $v['ai'] == true) { $q .= " AUTO_INCREMENT"; } if ((isset($v['unique']) && $v['unique'] == true) && (isset($v['primary']) && $v['primary'] == true)) { die ("Unique or Primary?"); } if (isset($v['unique']) && $v['unique'] == true) { $q .= " UNIQUE"; } if (isset($v['primary']) && $v['primary'] == true) { $q .= " PRIMARY KEY"; } if (isset($v['foreign']) && isset($v['foreign']['table']) && isset($v['foreign']['column'])) { $q .= " ,FOREIGN KEY ({$key}) REFERENCES {$v['foreign']['table']}({$v['foreign']['column']})"; if (isset($v['foreign']['delete']) && $v['foreign']['delete'] == true) { $q .= " ON DELETE CASCADE"; } if (isset($v['foreign']['update']) && $v['foreign']['update'] == true) { $q .= " ON UPDATE CASCADE"; } } $q .= ", "; } else { die ("Please set type of column "); } } $q = substr($q, 0, -2); $q .= ")"; return $this->executeQuery($q); }
php
public function createTable($name, $data) { $q = "CREATE TABLE {$name} ("; foreach ($data as $key => $v) { $q .= $key; if (isset($v['type'])) { $q .= " {$v['type']}"; if (isset($v['length'])) { $q .= "({$v['length']})"; } else { if ($v['type'] != 'int' && $v['type'] != 'datetime') { die ("Please set length for table: {$name} - column: {$key}"); } } if (isset($v['unsigned']) && $v['unsigned'] == true) { $q .= " UNSIGNED"; } if (!isset($v['null']) || $v['null'] == false) { $q .= " NOT NULL"; } if (isset($v['default'])) { if (is_string($v['default'])) { $v['default'] = "'{$v['default']}'"; } $q .= " DEFAULT {$v['default']}"; } if (isset($v['ai']) && $v['ai'] == true) { $q .= " AUTO_INCREMENT"; } if ((isset($v['unique']) && $v['unique'] == true) && (isset($v['primary']) && $v['primary'] == true)) { die ("Unique or Primary?"); } if (isset($v['unique']) && $v['unique'] == true) { $q .= " UNIQUE"; } if (isset($v['primary']) && $v['primary'] == true) { $q .= " PRIMARY KEY"; } if (isset($v['foreign']) && isset($v['foreign']['table']) && isset($v['foreign']['column'])) { $q .= " ,FOREIGN KEY ({$key}) REFERENCES {$v['foreign']['table']}({$v['foreign']['column']})"; if (isset($v['foreign']['delete']) && $v['foreign']['delete'] == true) { $q .= " ON DELETE CASCADE"; } if (isset($v['foreign']['update']) && $v['foreign']['update'] == true) { $q .= " ON UPDATE CASCADE"; } } $q .= ", "; } else { die ("Please set type of column "); } } $q = substr($q, 0, -2); $q .= ")"; return $this->executeQuery($q); }
[ "public", "function", "createTable", "(", "$", "name", ",", "$", "data", ")", "{", "$", "q", "=", "\"CREATE TABLE {$name} (\"", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "v", ")", "{", "$", "q", ".=", "$", "key", ";", "if", "...
Create new table @param string $name Name of table @param array $data Array with table definition @return bool
[ "Create", "new", "table" ]
ff7a4f69f8ee7beb37adee348b67d1be84c51ff1
https://github.com/crater-framework/crater-php-framework/blob/ff7a4f69f8ee7beb37adee348b67d1be84c51ff1/Migration.php#L68-L139
train
bariew/yii2-notice-cms-module
models/EmailConfig.php
EmailConfig.createEventConfig
public static function createEventConfig(Event $event) { if ($event->sender->handler_class != Item::className() || $event->sender->handler_method != Item::HANDLER_METHOD ) { return false; } $model = new self([ 'title' => 'new config', 'content' => 'new content', 'subject' => 'new subject', 'owner_name' => $event->sender->trigger_class, 'owner_event'=> $event->sender->trigger_event, 'address' => 'test@test.com' ]); $model->save(); }
php
public static function createEventConfig(Event $event) { if ($event->sender->handler_class != Item::className() || $event->sender->handler_method != Item::HANDLER_METHOD ) { return false; } $model = new self([ 'title' => 'new config', 'content' => 'new content', 'subject' => 'new subject', 'owner_name' => $event->sender->trigger_class, 'owner_event'=> $event->sender->trigger_event, 'address' => 'test@test.com' ]); $model->save(); }
[ "public", "static", "function", "createEventConfig", "(", "Event", "$", "event", ")", "{", "if", "(", "$", "event", "->", "sender", "->", "handler_class", "!=", "Item", "::", "className", "(", ")", "||", "$", "event", "->", "sender", "->", "handler_method"...
For autocreate config from new event module items. @param Event $event event model new item event. @return bool
[ "For", "autocreate", "config", "from", "new", "event", "module", "items", "." ]
1dc9798b3ed2c511937e9d3e44867412c9f5a7b6
https://github.com/bariew/yii2-notice-cms-module/blob/1dc9798b3ed2c511937e9d3e44867412c9f5a7b6/models/EmailConfig.php#L45-L61
train
ironedgesoftware/common-utils
src/Data/DataTrait.php
DataTrait.setData
public function setData(array $data, $replaceTemplateVariables = true) : self { $this->assertDataIsWritable(); if ($replaceTemplateVariables) { $data = $this->replaceTemplateVariables($data); } $this->_data = $data; return $this; }
php
public function setData(array $data, $replaceTemplateVariables = true) : self { $this->assertDataIsWritable(); if ($replaceTemplateVariables) { $data = $this->replaceTemplateVariables($data); } $this->_data = $data; return $this; }
[ "public", "function", "setData", "(", "array", "$", "data", ",", "$", "replaceTemplateVariables", "=", "true", ")", ":", "self", "{", "$", "this", "->", "assertDataIsWritable", "(", ")", ";", "if", "(", "$", "replaceTemplateVariables", ")", "{", "$", "data...
Setter method for field data. @param array $data - data. @param bool $replaceTemplateVariables - Replace template variables? @throws DataIsReadOnlyException - If data is on read-only status. @return $this
[ "Setter", "method", "for", "field", "data", "." ]
1cbe4c77a4abeb17a45250b9b86353457ce6c2b4
https://github.com/ironedgesoftware/common-utils/blob/1cbe4c77a4abeb17a45250b9b86353457ce6c2b4/src/Data/DataTrait.php#L77-L88
train
ironedgesoftware/common-utils
src/Data/DataTrait.php
DataTrait.replaceTemplateVariables
public function replaceTemplateVariables($data) { $this->assertDataIsWritable(); if ($templateVariables = $this->getOption('templateVariables', [])) { $templateVariableKeys = array_keys($templateVariables); if (is_string($data)) { $data = str_replace($templateVariableKeys, $templateVariables, $data); } else if (is_array($data)) { array_walk_recursive( $data, function(&$value, &$key, &$data) { $value = str_replace($data['keys'], $data['values'], $value); }, [ 'keys' => $templateVariableKeys, 'values' => $templateVariables ] ); } } return $data; }
php
public function replaceTemplateVariables($data) { $this->assertDataIsWritable(); if ($templateVariables = $this->getOption('templateVariables', [])) { $templateVariableKeys = array_keys($templateVariables); if (is_string($data)) { $data = str_replace($templateVariableKeys, $templateVariables, $data); } else if (is_array($data)) { array_walk_recursive( $data, function(&$value, &$key, &$data) { $value = str_replace($data['keys'], $data['values'], $value); }, [ 'keys' => $templateVariableKeys, 'values' => $templateVariables ] ); } } return $data; }
[ "public", "function", "replaceTemplateVariables", "(", "$", "data", ")", "{", "$", "this", "->", "assertDataIsWritable", "(", ")", ";", "if", "(", "$", "templateVariables", "=", "$", "this", "->", "getOption", "(", "'templateVariables'", ",", "[", "]", ")", ...
Replaces the data with the template variables configured on this instance. @param string|array $data - Data. @throws DataIsReadOnlyException - If data is on read-only status. @return string|array
[ "Replaces", "the", "data", "with", "the", "template", "variables", "configured", "on", "this", "instance", "." ]
1cbe4c77a4abeb17a45250b9b86353457ce6c2b4
https://github.com/ironedgesoftware/common-utils/blob/1cbe4c77a4abeb17a45250b9b86353457ce6c2b4/src/Data/DataTrait.php#L109-L133
train
ironedgesoftware/common-utils
src/Data/DataTrait.php
DataTrait.has
public function has(string $index, array $options = []) : bool { $separator = isset($options['separator']) ? $options['separator'] : $this->getOption('separator', '.'); $value = $this->getData(); $keys = explode($separator, $index); foreach ($keys as $key) { if (!is_array($value) || !array_key_exists($key, $value)) { return false; } $value = $value[$key]; } return true; }
php
public function has(string $index, array $options = []) : bool { $separator = isset($options['separator']) ? $options['separator'] : $this->getOption('separator', '.'); $value = $this->getData(); $keys = explode($separator, $index); foreach ($keys as $key) { if (!is_array($value) || !array_key_exists($key, $value)) { return false; } $value = $value[$key]; } return true; }
[ "public", "function", "has", "(", "string", "$", "index", ",", "array", "$", "options", "=", "[", "]", ")", ":", "bool", "{", "$", "separator", "=", "isset", "(", "$", "options", "[", "'separator'", "]", ")", "?", "$", "options", "[", "'separator'", ...
Returns true if the parameter exists or false otherwise. @param string $index - Index to search for. @param array $options - Options. @return bool
[ "Returns", "true", "if", "the", "parameter", "exists", "or", "false", "otherwise", "." ]
1cbe4c77a4abeb17a45250b9b86353457ce6c2b4
https://github.com/ironedgesoftware/common-utils/blob/1cbe4c77a4abeb17a45250b9b86353457ce6c2b4/src/Data/DataTrait.php#L268-L285
train
atorscho/menus
src/LoadMenus.php
LoadMenus.load
public function load() { // Make the $menu variable available to all files $menu = app('menu'); // Include menu files $files = $this->getFiles(); /** @var \SplFileInfo $file */ foreach ($files as $file) { require_once $file->getPath() . '/' . $file->getFilename(); } }
php
public function load() { // Make the $menu variable available to all files $menu = app('menu'); // Include menu files $files = $this->getFiles(); /** @var \SplFileInfo $file */ foreach ($files as $file) { require_once $file->getPath() . '/' . $file->getFilename(); } }
[ "public", "function", "load", "(", ")", "{", "// Make the $menu variable available to all files", "$", "menu", "=", "app", "(", "'menu'", ")", ";", "// Include menu files", "$", "files", "=", "$", "this", "->", "getFiles", "(", ")", ";", "/** @var \\SplFileInfo $f...
Load menus. @throws DirectoryNotFound @throws MenuFilesNotFound
[ "Load", "menus", "." ]
9ef049761e410018424a32e46a3360a8de1e374a
https://github.com/atorscho/menus/blob/9ef049761e410018424a32e46a3360a8de1e374a/src/LoadMenus.php#L33-L45
train
atorscho/menus
src/LoadMenus.php
LoadMenus.getPath
protected function getPath(): string { $directory = config('menus.directory'); if (! $directory) { throw new DirectoryNotFound('Directory with menu files does not exist.'); } $path = $this->file->exists(base_path($directory)) ? base_path($directory) : __DIR__ . '/../resources/menus'; return $path; }
php
protected function getPath(): string { $directory = config('menus.directory'); if (! $directory) { throw new DirectoryNotFound('Directory with menu files does not exist.'); } $path = $this->file->exists(base_path($directory)) ? base_path($directory) : __DIR__ . '/../resources/menus'; return $path; }
[ "protected", "function", "getPath", "(", ")", ":", "string", "{", "$", "directory", "=", "config", "(", "'menus.directory'", ")", ";", "if", "(", "!", "$", "directory", ")", "{", "throw", "new", "DirectoryNotFound", "(", "'Directory with menu files does not exis...
Get path to the directory with menus files.
[ "Get", "path", "to", "the", "directory", "with", "menus", "files", "." ]
9ef049761e410018424a32e46a3360a8de1e374a
https://github.com/atorscho/menus/blob/9ef049761e410018424a32e46a3360a8de1e374a/src/LoadMenus.php#L50-L61
train
atorscho/menus
src/LoadMenus.php
LoadMenus.getFiles
protected function getFiles(): array { $path = $this->getPath(); $files = $this->file->allFiles($path); if (! $files) { throw new MenuFilesNotFound("Menu files have not been found in [{$path}]."); } return $files; }
php
protected function getFiles(): array { $path = $this->getPath(); $files = $this->file->allFiles($path); if (! $files) { throw new MenuFilesNotFound("Menu files have not been found in [{$path}]."); } return $files; }
[ "protected", "function", "getFiles", "(", ")", ":", "array", "{", "$", "path", "=", "$", "this", "->", "getPath", "(", ")", ";", "$", "files", "=", "$", "this", "->", "file", "->", "allFiles", "(", "$", "path", ")", ";", "if", "(", "!", "$", "f...
Get menu files from the specified directory.
[ "Get", "menu", "files", "from", "the", "specified", "directory", "." ]
9ef049761e410018424a32e46a3360a8de1e374a
https://github.com/atorscho/menus/blob/9ef049761e410018424a32e46a3360a8de1e374a/src/LoadMenus.php#L66-L77
train
marando/phpSOFA
src/Marando/IAU/iauTf2d.php
iauTf2d.Tf2d
public static function Tf2d($s, $ihour, $imin, $sec, &$days) { /* Compute the interval. */ $days = ( $s == '-' ? -1.0 : 1.0 ) * ( 60.0 * ( 60.0 * ( (double)abs($ihour) ) + ( (double)abs($imin) ) ) + abs($sec) ) / DAYSEC; /* Validate arguments and return status. */ if ($ihour < 0 || $ihour > 23) return 1; if ($imin < 0 || $imin > 59) return 2; if ($sec < 0.0 || $sec >= 60.0) return 3; return 0; }
php
public static function Tf2d($s, $ihour, $imin, $sec, &$days) { /* Compute the interval. */ $days = ( $s == '-' ? -1.0 : 1.0 ) * ( 60.0 * ( 60.0 * ( (double)abs($ihour) ) + ( (double)abs($imin) ) ) + abs($sec) ) / DAYSEC; /* Validate arguments and return status. */ if ($ihour < 0 || $ihour > 23) return 1; if ($imin < 0 || $imin > 59) return 2; if ($sec < 0.0 || $sec >= 60.0) return 3; return 0; }
[ "public", "static", "function", "Tf2d", "(", "$", "s", ",", "$", "ihour", ",", "$", "imin", ",", "$", "sec", ",", "&", "$", "days", ")", "{", "/* Compute the interval. */", "$", "days", "=", "(", "$", "s", "==", "'-'", "?", "-", "1.0", ":", "1.0"...
- - - - - - - - i a u T f 2 d - - - - - - - - Convert hours, minutes, seconds to days. This function is part of the International Astronomical Union's SOFA (Standards of Fundamental Astronomy) software collection. Status: support function. Given: s char sign: '-' = negative, otherwise positive ihour int hours imin int minutes sec double seconds Returned: days double interval in days Returned (function value): int status: 0 = OK 1 = ihour outside range 0-23 2 = imin outside range 0-59 3 = sec outside range 0-59.999... Notes: 1) The result is computed even if any of the range checks fail. 2) Negative ihour, imin and/or sec produce a warning status, but the absolute value is used in the conversion. 3) If there are multiple errors, the status value reflects only the first, the smallest taking precedence. This revision: 2013 June 18 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "-", "-", "i", "a", "u", "T", "f", "2", "d", "-", "-", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauTf2d.php#L50-L65
train
TreasurerPHP/Gateway-Stripe
src/StripeGateway.php
StripeGateway.charge
public function charge(InvoicePayment $payment) { // Make a charge through Stripe try { $charge = Charge::create([ // Multiply by 100 as Stripe charges in pence. 'amount' => $payment->amount * 100, 'currency' => 'gbp', 'description' => 'Invoice payment', 'metadata' => [ 'invoice_id' => $payment->invoice->id ], 'source' => $payment->getPreCommitMetadataArray()['STRIPE_TOKEN'], ]); // Add Stripe payment ID to invoice payment $payment->payment_id = $charge->id; $responseMeta = new InvoicePaymentMetadata(); $responseMeta->key = 'GATEWAY_RESPONSE'; $responseMeta->value = $charge->status; $payment->metadata()->save($responseMeta); $payment->save(); return true; } catch(Card $cardError) { $payment->payment_id = $cardError->getJsonBody()['error']['charge']; $responseMeta = new InvoicePaymentMetadata(); $responseMeta->key = 'GATEWAY_RESPONSE'; $responseMeta->value = $cardError->getMessage(); $payment->metadata()->save($responseMeta); $payment->save(); return false; } }
php
public function charge(InvoicePayment $payment) { // Make a charge through Stripe try { $charge = Charge::create([ // Multiply by 100 as Stripe charges in pence. 'amount' => $payment->amount * 100, 'currency' => 'gbp', 'description' => 'Invoice payment', 'metadata' => [ 'invoice_id' => $payment->invoice->id ], 'source' => $payment->getPreCommitMetadataArray()['STRIPE_TOKEN'], ]); // Add Stripe payment ID to invoice payment $payment->payment_id = $charge->id; $responseMeta = new InvoicePaymentMetadata(); $responseMeta->key = 'GATEWAY_RESPONSE'; $responseMeta->value = $charge->status; $payment->metadata()->save($responseMeta); $payment->save(); return true; } catch(Card $cardError) { $payment->payment_id = $cardError->getJsonBody()['error']['charge']; $responseMeta = new InvoicePaymentMetadata(); $responseMeta->key = 'GATEWAY_RESPONSE'; $responseMeta->value = $cardError->getMessage(); $payment->metadata()->save($responseMeta); $payment->save(); return false; } }
[ "public", "function", "charge", "(", "InvoicePayment", "$", "payment", ")", "{", "// Make a charge through Stripe", "try", "{", "$", "charge", "=", "Charge", "::", "create", "(", "[", "// Multiply by 100 as Stripe charges in pence.", "'amount'", "=>", "$", "payment", ...
Make a charge using Stripe. @param InvoicePayment $payment @return bool Whether or not the charge succeeded
[ "Make", "a", "charge", "using", "Stripe", "." ]
0af657b68956ed3571407643586c1009e7cf4832
https://github.com/TreasurerPHP/Gateway-Stripe/blob/0af657b68956ed3571407643586c1009e7cf4832/src/StripeGateway.php#L34-L72
train
hschulz/php-network-stuff
src/IPv4.php
IPv4.parse
protected function parse(): void { switch ($this->notation) { case self::NOTATION_DOT_DECIMAL: $this->fromDotDecimal($this->value); break; case self::NOTATION_BINARY: $this->fromBinary($this->value); break; case self::NOTATION_CIDR_SHORT: $this->fromCidrShort($this->value); break; case self::NOTATION_CIDR_LONG: $this->fromCidrLong($this->value); break; case self::NOTATION_CIDR_BINARY: $this->fromCidrBinary($this->value); break; default: $this->notation = self::NOTATION_INVALID; } }
php
protected function parse(): void { switch ($this->notation) { case self::NOTATION_DOT_DECIMAL: $this->fromDotDecimal($this->value); break; case self::NOTATION_BINARY: $this->fromBinary($this->value); break; case self::NOTATION_CIDR_SHORT: $this->fromCidrShort($this->value); break; case self::NOTATION_CIDR_LONG: $this->fromCidrLong($this->value); break; case self::NOTATION_CIDR_BINARY: $this->fromCidrBinary($this->value); break; default: $this->notation = self::NOTATION_INVALID; } }
[ "protected", "function", "parse", "(", ")", ":", "void", "{", "switch", "(", "$", "this", "->", "notation", ")", "{", "case", "self", "::", "NOTATION_DOT_DECIMAL", ":", "$", "this", "->", "fromDotDecimal", "(", "$", "this", "->", "value", ")", ";", "br...
Parses the given value into the desired format. @return void
[ "Parses", "the", "given", "value", "into", "the", "desired", "format", "." ]
8d9f60bb5061f7df6ef3afbd1df4966533263d77
https://github.com/hschulz/php-network-stuff/blob/8d9f60bb5061f7df6ef3afbd1df4966533263d77/src/IPv4.php#L119-L146
train
hschulz/php-network-stuff
src/IPv4.php
IPv4.isValid
public function isValid(): bool { $segments = explode('.', $this->value, self::NUM_SEGMENTS); if (count($segments) !== self::NUM_SEGMENTS) { return false; } for ($i = 0; $i < self::NUM_SEGMENTS; $i++) { $value = (int) $segments[$i]; if ($value < self::MIN_VALUE || $value > self::MAX_VALUE) { return false; } } return true; }
php
public function isValid(): bool { $segments = explode('.', $this->value, self::NUM_SEGMENTS); if (count($segments) !== self::NUM_SEGMENTS) { return false; } for ($i = 0; $i < self::NUM_SEGMENTS; $i++) { $value = (int) $segments[$i]; if ($value < self::MIN_VALUE || $value > self::MAX_VALUE) { return false; } } return true; }
[ "public", "function", "isValid", "(", ")", ":", "bool", "{", "$", "segments", "=", "explode", "(", "'.'", ",", "$", "this", "->", "value", ",", "self", "::", "NUM_SEGMENTS", ")", ";", "if", "(", "count", "(", "$", "segments", ")", "!==", "self", ":...
Test each segment of the addess to be within the MIN_VALUE and MAX_VALUE. @return bool Returns true if the ip address is valid
[ "Test", "each", "segment", "of", "the", "addess", "to", "be", "within", "the", "MIN_VALUE", "and", "MAX_VALUE", "." ]
8d9f60bb5061f7df6ef3afbd1df4966533263d77
https://github.com/hschulz/php-network-stuff/blob/8d9f60bb5061f7df6ef3afbd1df4966533263d77/src/IPv4.php#L153-L170
train
phlexible/phlexible
src/Phlexible/Bundle/ProblemBundle/Entity/Problem.php
Problem.toArray
public function toArray() { return [ 'severity' => $this->severity, 'msg' => $this->msg, 'hint' => $this->hint, 'link' => !empty($this->link) ? $this->link : null, 'iconCls' => $this->iconClass, ]; }
php
public function toArray() { return [ 'severity' => $this->severity, 'msg' => $this->msg, 'hint' => $this->hint, 'link' => !empty($this->link) ? $this->link : null, 'iconCls' => $this->iconClass, ]; }
[ "public", "function", "toArray", "(", ")", "{", "return", "[", "'severity'", "=>", "$", "this", "->", "severity", ",", "'msg'", "=>", "$", "this", "->", "msg", ",", "'hint'", "=>", "$", "this", "->", "hint", ",", "'link'", "=>", "!", "empty", "(", ...
Return array represantation of this problem. @return array
[ "Return", "array", "represantation", "of", "this", "problem", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/ProblemBundle/Entity/Problem.php#L321-L330
train
phossa2/libs
src/Phossa2/Cache/Extension/ByPass.php
ByPass.byPassCache
public function byPassCache(EventInterface $event)/*# : bool */ { /* @var CachePool $pool */ $pool = $event->getTarget(); if ($this->trigger === '' || isset($_REQUEST[$this->trigger])) { return $pool->setError( Message::get(Message::CACHE_EXT_BYPASS), Message::CACHE_EXT_BYPASS ); } else { return true; } }
php
public function byPassCache(EventInterface $event)/*# : bool */ { /* @var CachePool $pool */ $pool = $event->getTarget(); if ($this->trigger === '' || isset($_REQUEST[$this->trigger])) { return $pool->setError( Message::get(Message::CACHE_EXT_BYPASS), Message::CACHE_EXT_BYPASS ); } else { return true; } }
[ "public", "function", "byPassCache", "(", "EventInterface", "$", "event", ")", "/*# : bool */", "{", "/* @var CachePool $pool */", "$", "pool", "=", "$", "event", "->", "getTarget", "(", ")", ";", "if", "(", "$", "this", "->", "trigger", "===", "''", "||", ...
Skip the cache 1. $this->trigger = '', always bypass the cache 2. if sees $this->trigger in $_REQUEST, bypass the cache @param EventInterface $event @return bool @access public
[ "Skip", "the", "cache" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Cache/Extension/ByPass.php#L80-L93
train
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-stdlib/src/FastPriorityQueue.php
FastPriorityQueue.insert
public function insert($value, $priority) { if (! is_int($priority)) { throw new Exception\InvalidArgumentException('The priority must be an integer'); } $this->values[$priority][] = $value; if (! isset($this->priorities[$priority])) { $this->priorities[$priority] = $priority; $this->maxPriority = max($priority, $this->maxPriority); } ++$this->count; }
php
public function insert($value, $priority) { if (! is_int($priority)) { throw new Exception\InvalidArgumentException('The priority must be an integer'); } $this->values[$priority][] = $value; if (! isset($this->priorities[$priority])) { $this->priorities[$priority] = $priority; $this->maxPriority = max($priority, $this->maxPriority); } ++$this->count; }
[ "public", "function", "insert", "(", "$", "value", ",", "$", "priority", ")", "{", "if", "(", "!", "is_int", "(", "$", "priority", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "'The priority must be an integer'", ")", ";...
Insert an element in the queue with a specified priority @param mixed $value @param integer $priority a positive integer
[ "Insert", "an", "element", "in", "the", "queue", "with", "a", "specified", "priority" ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/FastPriorityQueue.php#L91-L102
train