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
mylukin/pscws4
tools/xdb.class.php
XTreeDB._optimize_index
function _optimize_index($index) { static $cmp = false; $poff = $index * 8 + 32; // save all nodes into array() $this->_sync_nodes = array(); $this->_load_tree_nodes($poff); $count = count($this->_sync_nodes); if ($count < 3) return; // sync the nodes, sort by key first if ($cmp == false) $cmp = create_function('$a,$b', 'return strcmp($a[key],$b[key]);'); usort($this->_sync_nodes, $cmp); $this->_reset_tree_nodes($poff, 0, $count - 1); unset($this->_sync_nodes); }
php
function _optimize_index($index) { static $cmp = false; $poff = $index * 8 + 32; // save all nodes into array() $this->_sync_nodes = array(); $this->_load_tree_nodes($poff); $count = count($this->_sync_nodes); if ($count < 3) return; // sync the nodes, sort by key first if ($cmp == false) $cmp = create_function('$a,$b', 'return strcmp($a[key],$b[key]);'); usort($this->_sync_nodes, $cmp); $this->_reset_tree_nodes($poff, 0, $count - 1); unset($this->_sync_nodes); }
[ "function", "_optimize_index", "(", "$", "index", ")", "{", "static", "$", "cmp", "=", "false", ";", "$", "poff", "=", "$", "index", "*", "8", "+", "32", ";", "// save all nodes into array()", "$", "this", "->", "_sync_nodes", "=", "array", "(", ")", "...
optimize a node
[ "optimize", "a", "node" ]
b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b
https://github.com/mylukin/pscws4/blob/b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b/tools/xdb.class.php#L434-L451
train
mylukin/pscws4
tools/xdb.class.php
XTreeDB._load_tree_nodes
function _load_tree_nodes($poff) { fseek($this->fd, $poff, SEEK_SET); $buf = fread($this->fd, 8); if (strlen($buf) != 8) return; $tmp = unpack('Ioff/Ilen', $buf); if ($tmp['len'] == 0) return; fseek($this->fd, $tmp['off'], SEEK_SET); $rlen = XDB_MAXKLEN + 17; if ($rlen > $tmp['len']) $rlen = $tmp['len']; $buf = fread($this->fd, $rlen); $rec = unpack('Iloff/Illen/Iroff/Irlen/Cklen', substr($buf, 0, 17)); $rec['off'] = $tmp['off']; $rec['len'] = $tmp['len']; $rec['key'] = substr($buf, 17, $rec['klen']); $this->_sync_nodes[] = $rec; unset($buf); // left if ($rec['llen'] != 0) $this->_load_tree_nodes($tmp['off']); // right if ($rec['rlen'] != 0) $this->_load_tree_nodes($tmp['off'] + 8); }
php
function _load_tree_nodes($poff) { fseek($this->fd, $poff, SEEK_SET); $buf = fread($this->fd, 8); if (strlen($buf) != 8) return; $tmp = unpack('Ioff/Ilen', $buf); if ($tmp['len'] == 0) return; fseek($this->fd, $tmp['off'], SEEK_SET); $rlen = XDB_MAXKLEN + 17; if ($rlen > $tmp['len']) $rlen = $tmp['len']; $buf = fread($this->fd, $rlen); $rec = unpack('Iloff/Illen/Iroff/Irlen/Cklen', substr($buf, 0, 17)); $rec['off'] = $tmp['off']; $rec['len'] = $tmp['len']; $rec['key'] = substr($buf, 17, $rec['klen']); $this->_sync_nodes[] = $rec; unset($buf); // left if ($rec['llen'] != 0) $this->_load_tree_nodes($tmp['off']); // right if ($rec['rlen'] != 0) $this->_load_tree_nodes($tmp['off'] + 8); }
[ "function", "_load_tree_nodes", "(", "$", "poff", ")", "{", "fseek", "(", "$", "this", "->", "fd", ",", "$", "poff", ",", "SEEK_SET", ")", ";", "$", "buf", "=", "fread", "(", "$", "this", "->", "fd", ",", "8", ")", ";", "if", "(", "strlen", "("...
load tree nodes
[ "load", "tree", "nodes" ]
b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b
https://github.com/mylukin/pscws4/blob/b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b/tools/xdb.class.php#L454-L479
train
mylukin/pscws4
tools/xdb.class.php
XTreeDB._reset_tree_nodes
function _reset_tree_nodes($poff, $low, $high) { if ($low <= $high) { $mid = ($low+$high)>>1; $node = $this->_sync_nodes[$mid]; $buf = pack('II', $node['off'], $node['len']); // left $this->_reset_tree_nodes($node['off'], $low, $mid - 1); // right $this->_reset_tree_nodes($node['off'] + 8, $mid + 1, $high); } else { $buf = pack('II', 0, 0); } fseek($this->fd, $poff, SEEK_SET); fwrite($this->fd, $buf, 8); }
php
function _reset_tree_nodes($poff, $low, $high) { if ($low <= $high) { $mid = ($low+$high)>>1; $node = $this->_sync_nodes[$mid]; $buf = pack('II', $node['off'], $node['len']); // left $this->_reset_tree_nodes($node['off'], $low, $mid - 1); // right $this->_reset_tree_nodes($node['off'] + 8, $mid + 1, $high); } else { $buf = pack('II', 0, 0); } fseek($this->fd, $poff, SEEK_SET); fwrite($this->fd, $buf, 8); }
[ "function", "_reset_tree_nodes", "(", "$", "poff", ",", "$", "low", ",", "$", "high", ")", "{", "if", "(", "$", "low", "<=", "$", "high", ")", "{", "$", "mid", "=", "(", "$", "low", "+", "$", "high", ")", ">>", "1", ";", "$", "node", "=", "...
sync the tree
[ "sync", "the", "tree" ]
b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b
https://github.com/mylukin/pscws4/blob/b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b/tools/xdb.class.php#L482-L502
train
mylukin/pscws4
tools/xdb.class.php
XTreeDB._check_header
function _check_header($fd) { fseek($fd, 0, SEEK_SET); $buf = fread($fd, 32); if (strlen($buf) !== 32) return false; $hdr = unpack('a3tag/Cver/Ibase/Iprime/Ifsize/fcheck/a12reversed', $buf); if ($hdr['tag'] != XDB_TAGNAME) return false; // check the fsize $fstat = fstat($fd); if ($fstat['size'] != $hdr['fsize']) return false; // check float? $this->hash_base = $hdr['base']; $this->hash_prime = $hdr['prime']; $this->version = $hdr['ver']; $this->fsize = $hdr['fsize']; return true; }
php
function _check_header($fd) { fseek($fd, 0, SEEK_SET); $buf = fread($fd, 32); if (strlen($buf) !== 32) return false; $hdr = unpack('a3tag/Cver/Ibase/Iprime/Ifsize/fcheck/a12reversed', $buf); if ($hdr['tag'] != XDB_TAGNAME) return false; // check the fsize $fstat = fstat($fd); if ($fstat['size'] != $hdr['fsize']) return false; // check float? $this->hash_base = $hdr['base']; $this->hash_prime = $hdr['prime']; $this->version = $hdr['ver']; $this->fsize = $hdr['fsize']; return true; }
[ "function", "_check_header", "(", "$", "fd", ")", "{", "fseek", "(", "$", "fd", ",", "0", ",", "SEEK_SET", ")", ";", "$", "buf", "=", "fread", "(", "$", "fd", ",", "32", ")", ";", "if", "(", "strlen", "(", "$", "buf", ")", "!==", "32", ")", ...
Check XDB Header
[ "Check", "XDB", "Header" ]
b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b
https://github.com/mylukin/pscws4/blob/b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b/tools/xdb.class.php#L558-L578
train
mylukin/pscws4
tools/xdb.class.php
XTreeDB._write_header
function _write_header($fd) { $buf = pack('a3CiiIfa12', XDB_TAGNAME, $this->version, $this->hash_base, $this->hash_prime, 0, XDB_FLOAT_CHECK, ''); fseek($fd, 0, SEEK_SET); fwrite($fd, $buf, 32); }
php
function _write_header($fd) { $buf = pack('a3CiiIfa12', XDB_TAGNAME, $this->version, $this->hash_base, $this->hash_prime, 0, XDB_FLOAT_CHECK, ''); fseek($fd, 0, SEEK_SET); fwrite($fd, $buf, 32); }
[ "function", "_write_header", "(", "$", "fd", ")", "{", "$", "buf", "=", "pack", "(", "'a3CiiIfa12'", ",", "XDB_TAGNAME", ",", "$", "this", "->", "version", ",", "$", "this", "->", "hash_base", ",", "$", "this", "->", "hash_prime", ",", "0", ",", "XDB...
Write XDB Header
[ "Write", "XDB", "Header" ]
b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b
https://github.com/mylukin/pscws4/blob/b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b/tools/xdb.class.php#L581-L588
train
mylukin/pscws4
tools/xdb.class.php
XTreeDB._get_record
function _get_record($key) { $this->_io_times = 1; $index = ($this->hash_prime > 1 ? $this->_get_index($key) : 0); $poff = $index * 8 + 32; fseek($this->fd, $poff, SEEK_SET); $buf = fread($this->fd, 8); if (strlen($buf) == 8) $tmp = unpack('Ioff/Ilen', $buf); else $tmp = array('off' => 0, 'len' => 0); return $this->_tree_get_record($tmp['off'], $tmp['len'], $poff, $key); }
php
function _get_record($key) { $this->_io_times = 1; $index = ($this->hash_prime > 1 ? $this->_get_index($key) : 0); $poff = $index * 8 + 32; fseek($this->fd, $poff, SEEK_SET); $buf = fread($this->fd, 8); if (strlen($buf) == 8) $tmp = unpack('Ioff/Ilen', $buf); else $tmp = array('off' => 0, 'len' => 0); return $this->_tree_get_record($tmp['off'], $tmp['len'], $poff, $key); }
[ "function", "_get_record", "(", "$", "key", ")", "{", "$", "this", "->", "_io_times", "=", "1", ";", "$", "index", "=", "(", "$", "this", "->", "hash_prime", ">", "1", "?", "$", "this", "->", "_get_index", "(", "$", "key", ")", ":", "0", ")", "...
get the record by first key
[ "get", "the", "record", "by", "first", "key" ]
b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b
https://github.com/mylukin/pscws4/blob/b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b/tools/xdb.class.php#L591-L602
train
mylukin/pscws4
tools/xdb.class.php
XTreeDB._tree_get_record
function _tree_get_record($off, $len, $poff = 0, $key = '') { if ($len == 0) return (array('poff' => $poff)); $this->_io_times++; // get the data & compare the key data fseek($this->fd, $off, SEEK_SET); $rlen = XDB_MAXKLEN + 17; if ($rlen > $len) $rlen = $len; $buf = fread($this->fd, $rlen); $rec = unpack('Iloff/Illen/Iroff/Irlen/Cklen', substr($buf, 0, 17)); $fkey = substr($buf, 17, $rec['klen']); $cmp = ($key ? strcmp($key, $fkey) : 0); if ($cmp > 0) { // --> right unset($buf); return $this->_tree_get_record($rec['roff'], $rec['rlen'], $off + 8, $key); } else if ($cmp < 0) { // <-- left unset($buf); return $this->_tree_get_record($rec['loff'], $rec['llen'], $off, $key); } else { // found!! $rec['poff'] = $poff; $rec['off'] = $off; $rec['len'] = $len; $rec['voff'] = $off + 17 + $rec['klen']; $rec['vlen'] = $len - 17 - $rec['klen']; $rec['key'] = $fkey; fseek($this->fd, $rec['voff'], SEEK_SET); $rec['value'] = fread($this->fd, $rec['vlen']); return $rec; } }
php
function _tree_get_record($off, $len, $poff = 0, $key = '') { if ($len == 0) return (array('poff' => $poff)); $this->_io_times++; // get the data & compare the key data fseek($this->fd, $off, SEEK_SET); $rlen = XDB_MAXKLEN + 17; if ($rlen > $len) $rlen = $len; $buf = fread($this->fd, $rlen); $rec = unpack('Iloff/Illen/Iroff/Irlen/Cklen', substr($buf, 0, 17)); $fkey = substr($buf, 17, $rec['klen']); $cmp = ($key ? strcmp($key, $fkey) : 0); if ($cmp > 0) { // --> right unset($buf); return $this->_tree_get_record($rec['roff'], $rec['rlen'], $off + 8, $key); } else if ($cmp < 0) { // <-- left unset($buf); return $this->_tree_get_record($rec['loff'], $rec['llen'], $off, $key); } else { // found!! $rec['poff'] = $poff; $rec['off'] = $off; $rec['len'] = $len; $rec['voff'] = $off + 17 + $rec['klen']; $rec['vlen'] = $len - 17 - $rec['klen']; $rec['key'] = $fkey; fseek($this->fd, $rec['voff'], SEEK_SET); $rec['value'] = fread($this->fd, $rec['vlen']); return $rec; } }
[ "function", "_tree_get_record", "(", "$", "off", ",", "$", "len", ",", "$", "poff", "=", "0", ",", "$", "key", "=", "''", ")", "{", "if", "(", "$", "len", "==", "0", ")", "return", "(", "array", "(", "'poff'", "=>", "$", "poff", ")", ")", ";"...
get the record by tree
[ "get", "the", "record", "by", "tree" ]
b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b
https://github.com/mylukin/pscws4/blob/b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b/tools/xdb.class.php#L605-L644
train
dionsnoeijen/sexy-field
src/SectionField/Service/ReadSection.php
ReadSection.read
public function read( ReadOptionsInterface $options, SectionConfig $sectionConfig = null ): \ArrayIterator { $sectionData = new \ArrayIterator(); $this->dispatcher->dispatch( SectionBeforeRead::NAME, new SectionBeforeRead($sectionData, $options, $sectionConfig) ); if ($sectionConfig === null && count($options->getSection()) > 0) { $sectionConfig = $this->sectionManager->readByHandle( $options->getSection()[0]->toHandle() )->getConfig(); } // Make sure we are passing the fully qualified class name as the section if (count($options->getSection()) > 0) { $optionsArray = $options->toArray(); $optionsArray[ReadOptions::SECTION] = (string)$sectionConfig->getFullyQualifiedClassName(); $options = ReadOptions::fromArray($optionsArray); } /** @var ReadSectionInterface $reader */ foreach ($this->readers as $reader) { foreach ($reader->read($options, $sectionConfig) as $entry) { $sectionData->append($entry); } } $this->dispatcher->dispatch( SectionDataRead::NAME, new SectionDataRead($sectionData, $options, $sectionConfig) ); return $sectionData; }
php
public function read( ReadOptionsInterface $options, SectionConfig $sectionConfig = null ): \ArrayIterator { $sectionData = new \ArrayIterator(); $this->dispatcher->dispatch( SectionBeforeRead::NAME, new SectionBeforeRead($sectionData, $options, $sectionConfig) ); if ($sectionConfig === null && count($options->getSection()) > 0) { $sectionConfig = $this->sectionManager->readByHandle( $options->getSection()[0]->toHandle() )->getConfig(); } // Make sure we are passing the fully qualified class name as the section if (count($options->getSection()) > 0) { $optionsArray = $options->toArray(); $optionsArray[ReadOptions::SECTION] = (string)$sectionConfig->getFullyQualifiedClassName(); $options = ReadOptions::fromArray($optionsArray); } /** @var ReadSectionInterface $reader */ foreach ($this->readers as $reader) { foreach ($reader->read($options, $sectionConfig) as $entry) { $sectionData->append($entry); } } $this->dispatcher->dispatch( SectionDataRead::NAME, new SectionDataRead($sectionData, $options, $sectionConfig) ); return $sectionData; }
[ "public", "function", "read", "(", "ReadOptionsInterface", "$", "options", ",", "SectionConfig", "$", "sectionConfig", "=", "null", ")", ":", "\\", "ArrayIterator", "{", "$", "sectionData", "=", "new", "\\", "ArrayIterator", "(", ")", ";", "$", "this", "->",...
Read from one or more data-sources @param ReadOptionsInterface $options @param SectionConfig|null $sectionConfig @return \ArrayIterator
[ "Read", "from", "one", "or", "more", "data", "-", "sources" ]
68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033
https://github.com/dionsnoeijen/sexy-field/blob/68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033/src/SectionField/Service/ReadSection.php#L49-L86
train
koolkode/async
src/Loop/NativeLoop.php
NativeLoop.nextTimeout
private function nextTimeout(): ?int { $time = \microtime(true); while (!$this->scheduler->isEmpty()) { list ($watcher, $scheduled) = $this->scheduler->top(); if ($watcher->enabled && $watcher->scheduled === $scheduled) { return (int) \max(0, ($watcher->due - $time) * 1000000); } } return null; }
php
private function nextTimeout(): ?int { $time = \microtime(true); while (!$this->scheduler->isEmpty()) { list ($watcher, $scheduled) = $this->scheduler->top(); if ($watcher->enabled && $watcher->scheduled === $scheduled) { return (int) \max(0, ($watcher->due - $time) * 1000000); } } return null; }
[ "private", "function", "nextTimeout", "(", ")", ":", "?", "int", "{", "$", "time", "=", "\\", "microtime", "(", "true", ")", ";", "while", "(", "!", "$", "this", "->", "scheduler", "->", "isEmpty", "(", ")", ")", "{", "list", "(", "$", "watcher", ...
Get the number of microseconds until the next timer watcher is due.
[ "Get", "the", "number", "of", "microseconds", "until", "the", "next", "timer", "watcher", "is", "due", "." ]
9c985dcdd3b328323826dd4254d9f2e5aea0b75b
https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/Loop/NativeLoop.php#L256-L269
train
koolkode/async
src/Loop/NativeLoop.php
NativeLoop.notifyPolls
private function notifyPolls(array $selected, array & $watchers): void { foreach ($selected as $k => $stream) { $k = $k ?: (int) $stream; if (isset($watchers[$k])) { foreach ($watchers[$k] as $watcher) { if (isset($watchers[$k][$watcher->id])) { ($watcher->callback)($watcher->id, $stream); } } } } }
php
private function notifyPolls(array $selected, array & $watchers): void { foreach ($selected as $k => $stream) { $k = $k ?: (int) $stream; if (isset($watchers[$k])) { foreach ($watchers[$k] as $watcher) { if (isset($watchers[$k][$watcher->id])) { ($watcher->callback)($watcher->id, $stream); } } } } }
[ "private", "function", "notifyPolls", "(", "array", "$", "selected", ",", "array", "&", "$", "watchers", ")", ":", "void", "{", "foreach", "(", "$", "selected", "as", "$", "k", "=>", "$", "stream", ")", "{", "$", "k", "=", "$", "k", "?", ":", "("...
Trigger all stream watchers for the selected resources. @param array $selected Streams being reported as readable / writable. @param array $watchers Watchers that might be triggered.
[ "Trigger", "all", "stream", "watchers", "for", "the", "selected", "resources", "." ]
9c985dcdd3b328323826dd4254d9f2e5aea0b75b
https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/Loop/NativeLoop.php#L277-L290
train
brightnucleus/view
src/View/View/AbstractView.php
AbstractView.addToContext
public function addToContext( string $key, $value, string $behavior ): View { switch ($behavior) { case View::REPLACE: $this->_context_[$key] = $value; return $this; case View::MERGE: if(array_key_exists($key, $this->_context_)) { $this->_context_ = array_merge_recursive($this->_context_, [$key => $value]); return $this; } $this->_context_[$key] = $value; return $this; case View::ADD_ONLY: if (array_key_exists($key, $this->_context_)) { return $this; } $this->_context_[$key] = $value; return $this; case View::REPLACE_ONLY: if (! array_key_exists($key, $this->_context_)) { return $this; } $this->_context_[$key] = $value; return $this; case View::MERGE_ONLY: if (! array_key_exists($key, $this->_context_)) { return $this; } $this->_context_ = array_merge_recursive($this->_context_, [$key => $value]); return $this; default: throw new InvalidContextAddingBehavior( sprintf( _('Invalid behavior "%s" for adding to the context of view "%s".'), $key, $this->_uri_ ) ); } }
php
public function addToContext( string $key, $value, string $behavior ): View { switch ($behavior) { case View::REPLACE: $this->_context_[$key] = $value; return $this; case View::MERGE: if(array_key_exists($key, $this->_context_)) { $this->_context_ = array_merge_recursive($this->_context_, [$key => $value]); return $this; } $this->_context_[$key] = $value; return $this; case View::ADD_ONLY: if (array_key_exists($key, $this->_context_)) { return $this; } $this->_context_[$key] = $value; return $this; case View::REPLACE_ONLY: if (! array_key_exists($key, $this->_context_)) { return $this; } $this->_context_[$key] = $value; return $this; case View::MERGE_ONLY: if (! array_key_exists($key, $this->_context_)) { return $this; } $this->_context_ = array_merge_recursive($this->_context_, [$key => $value]); return $this; default: throw new InvalidContextAddingBehavior( sprintf( _('Invalid behavior "%s" for adding to the context of view "%s".'), $key, $this->_uri_ ) ); } }
[ "public", "function", "addToContext", "(", "string", "$", "key", ",", "$", "value", ",", "string", "$", "behavior", ")", ":", "View", "{", "switch", "(", "$", "behavior", ")", "{", "case", "View", "::", "REPLACE", ":", "$", "this", "->", "_context_", ...
Add information to the context. @param string $key Context key to add. @param mixed $value Value to add under the given key. @param string $behavior Behavior to use for adapting the context. @return View
[ "Add", "information", "to", "the", "context", "." ]
f26703b78bf452403fda112563825f172dc9e8ce
https://github.com/brightnucleus/view/blob/f26703b78bf452403fda112563825f172dc9e8ce/src/View/View/AbstractView.php#L170-L210
train
brightnucleus/view
src/View/View/AbstractView.php
AbstractView.assimilateContext
protected function assimilateContext(array $context = []) { $this->_context_ = $context; foreach ($context as $key => $value) { $this->$key = $value; } }
php
protected function assimilateContext(array $context = []) { $this->_context_ = $context; foreach ($context as $key => $value) { $this->$key = $value; } }
[ "protected", "function", "assimilateContext", "(", "array", "$", "context", "=", "[", "]", ")", "{", "$", "this", "->", "_context_", "=", "$", "context", ";", "foreach", "(", "$", "context", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this"...
Assimilate the context to make it available as properties. @since 0.2.0 @param array $context Context to assimilate.
[ "Assimilate", "the", "context", "to", "make", "it", "available", "as", "properties", "." ]
f26703b78bf452403fda112563825f172dc9e8ce
https://github.com/brightnucleus/view/blob/f26703b78bf452403fda112563825f172dc9e8ce/src/View/View/AbstractView.php#L235-L241
train
thelia-modules/FeatureType
Model/Map/FeatureTypeI18nTableMap.php
FeatureTypeI18nTableMap.doDelete
public static function doDelete($values, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(FeatureTypeI18nTableMap::DATABASE_NAME); } if ($values instanceof Criteria) { // rename for clarity $criteria = $values; } elseif ($values instanceof \FeatureType\Model\FeatureTypeI18n) { // it's a model object // create criteria based on pk values $criteria = $values->buildPkeyCriteria(); } else { // it's a primary key, or an array of pks $criteria = new Criteria(FeatureTypeI18nTableMap::DATABASE_NAME); // primary key is composite; we therefore, expect // the primary key passed to be an array of pkey values if (count($values) == count($values, COUNT_RECURSIVE)) { // array is not multi-dimensional $values = array($values); } foreach ($values as $value) { $criterion = $criteria->getNewCriterion(FeatureTypeI18nTableMap::ID, $value[0]); $criterion->addAnd($criteria->getNewCriterion(FeatureTypeI18nTableMap::LOCALE, $value[1])); $criteria->addOr($criterion); } } $query = FeatureTypeI18nQuery::create()->mergeWith($criteria); if ($values instanceof Criteria) { FeatureTypeI18nTableMap::clearInstancePool(); } elseif (!is_object($values)) { // it's a primary key, or an array of pks foreach ((array) $values as $singleval) { FeatureTypeI18nTableMap::removeInstanceFromPool($singleval); } } return $query->delete($con); }
php
public static function doDelete($values, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(FeatureTypeI18nTableMap::DATABASE_NAME); } if ($values instanceof Criteria) { // rename for clarity $criteria = $values; } elseif ($values instanceof \FeatureType\Model\FeatureTypeI18n) { // it's a model object // create criteria based on pk values $criteria = $values->buildPkeyCriteria(); } else { // it's a primary key, or an array of pks $criteria = new Criteria(FeatureTypeI18nTableMap::DATABASE_NAME); // primary key is composite; we therefore, expect // the primary key passed to be an array of pkey values if (count($values) == count($values, COUNT_RECURSIVE)) { // array is not multi-dimensional $values = array($values); } foreach ($values as $value) { $criterion = $criteria->getNewCriterion(FeatureTypeI18nTableMap::ID, $value[0]); $criterion->addAnd($criteria->getNewCriterion(FeatureTypeI18nTableMap::LOCALE, $value[1])); $criteria->addOr($criterion); } } $query = FeatureTypeI18nQuery::create()->mergeWith($criteria); if ($values instanceof Criteria) { FeatureTypeI18nTableMap::clearInstancePool(); } elseif (!is_object($values)) { // it's a primary key, or an array of pks foreach ((array) $values as $singleval) { FeatureTypeI18nTableMap::removeInstanceFromPool($singleval); } } return $query->delete($con); }
[ "public", "static", "function", "doDelete", "(", "$", "values", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "if", "(", "null", "===", "$", "con", ")", "{", "$", "con", "=", "Propel", "::", "getServiceContainer", "(", ")", "->", "getW...
Performs a DELETE on the database, given a FeatureTypeI18n or Criteria object OR a primary key value. @param mixed $values Criteria or FeatureTypeI18n object or primary key or array of primary keys which is used to create the DELETE statement @param ConnectionInterface $con the connection to use @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows if supported by native driver or if emulated using Propel. @throws PropelException Any exceptions caught during processing will be rethrown wrapped into a PropelException.
[ "Performs", "a", "DELETE", "on", "the", "database", "given", "a", "FeatureTypeI18n", "or", "Criteria", "object", "OR", "a", "primary", "key", "value", "." ]
fc73eaaf53583758a316bb7e4af69ea50ec89997
https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Map/FeatureTypeI18nTableMap.php#L391-L427
train
kassko/data-mapper
src/LazyLoader/LazyLoader.php
LazyLoader.load
public function load($object) { if (get_class($object) !== $this->objectClass) { throw new \LogicException(sprintf('Invalid object type. Expected "%s" but got "%s".', $this->objectClass, get_class($object))); } $hydrator = $this->objectManager->getHydratorFor($this->objectClass); $hydrator->load($object); }
php
public function load($object) { if (get_class($object) !== $this->objectClass) { throw new \LogicException(sprintf('Invalid object type. Expected "%s" but got "%s".', $this->objectClass, get_class($object))); } $hydrator = $this->objectManager->getHydratorFor($this->objectClass); $hydrator->load($object); }
[ "public", "function", "load", "(", "$", "object", ")", "{", "if", "(", "get_class", "(", "$", "object", ")", "!==", "$", "this", "->", "objectClass", ")", "{", "throw", "new", "\\", "LogicException", "(", "sprintf", "(", "'Invalid object type. Expected \"%s\...
Load an object. Some properties can be loaded only when needed for performance reason. @param array $object The object for wich we have to load property @param array $propertyName The property to load
[ "Load", "an", "object", ".", "Some", "properties", "can", "be", "loaded", "only", "when", "needed", "for", "performance", "reason", "." ]
653b3d735977d95f6eadb3334ab8787db1dca275
https://github.com/kassko/data-mapper/blob/653b3d735977d95f6eadb3334ab8787db1dca275/src/LazyLoader/LazyLoader.php#L30-L38
train
kassko/data-mapper
src/LazyLoader/LazyLoader.php
LazyLoader.loadProperty
public function loadProperty($object, $propertyName) { if (get_class($object) !== $this->objectClass) { throw new \LogicException(sprintf('Invalid object type. Expected "%s" but got "%s".', $this->objectClass, get_class($object))); } if ($this->objectManager->isPropertyLoaded($object, $propertyName)) { return; } $hydrator = $this->objectManager->getHydratorFor($this->objectClass); $hydrator->loadProperty($object, $propertyName); }
php
public function loadProperty($object, $propertyName) { if (get_class($object) !== $this->objectClass) { throw new \LogicException(sprintf('Invalid object type. Expected "%s" but got "%s".', $this->objectClass, get_class($object))); } if ($this->objectManager->isPropertyLoaded($object, $propertyName)) { return; } $hydrator = $this->objectManager->getHydratorFor($this->objectClass); $hydrator->loadProperty($object, $propertyName); }
[ "public", "function", "loadProperty", "(", "$", "object", ",", "$", "propertyName", ")", "{", "if", "(", "get_class", "(", "$", "object", ")", "!==", "$", "this", "->", "objectClass", ")", "{", "throw", "new", "\\", "LogicException", "(", "sprintf", "(",...
Load an object property. This property can be loaded only if needed for performance reason. @param array $object The object for wich we have to load property @param array $propertyName The property to load
[ "Load", "an", "object", "property", ".", "This", "property", "can", "be", "loaded", "only", "if", "needed", "for", "performance", "reason", "." ]
653b3d735977d95f6eadb3334ab8787db1dca275
https://github.com/kassko/data-mapper/blob/653b3d735977d95f6eadb3334ab8787db1dca275/src/LazyLoader/LazyLoader.php#L47-L59
train
shardimage/shardimage-php
src/auth/Client.php
Client.defer
public function defer($enable) { $this->deferred = $enable; if (!$this->deferred && isset($this->request)) { return $this->doSend(); } }
php
public function defer($enable) { $this->deferred = $enable; if (!$this->deferred && isset($this->request)) { return $this->doSend(); } }
[ "public", "function", "defer", "(", "$", "enable", ")", "{", "$", "this", "->", "deferred", "=", "$", "enable", ";", "if", "(", "!", "$", "this", "->", "deferred", "&&", "isset", "(", "$", "this", "->", "request", ")", ")", "{", "return", "$", "t...
Setting up deferred request. If setting false and there are defered request, it will send together. @param bool $enable @return mixed
[ "Setting", "up", "deferred", "request", ".", "If", "setting", "false", "and", "there", "are", "defered", "request", "it", "will", "send", "together", "." ]
1988e3996dfdf7e17d1bd44d5d807f9884ac64bd
https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/auth/Client.php#L329-L336
train
shardimage/shardimage-php
src/auth/Client.php
Client.doSend
private function doSend() { try { if (!empty($this->sentContentIds) && count($this->sentContentIds) > $this->batchLimit) { throw new InvalidCallException(sprintf("Request limit reached! Max %d requests per batch is accepted!", $this->batchLimit)); } $response = $this->request->send(); $this->request = null; if ($response instanceof ApiResponse) { $response = [$response]; } $responses = []; $index = 0; foreach ($response as $_response) { $responses[$_response->id ?? $index] = $this->handleResponse($_response); $index++; } foreach ($this->sentContentIds as $sentContentId) { if (!array_key_exists($sentContentId, $responses)) { $responses[$sentContentId] = new ApiResponse([ 'success' => false, 'error' => new ResponseError([ 'type' => BadGatewayHttpException::class, 'code' => ResponseError::ERRORCODE_HTTP_RESPONSE_ERROR, 'message' => ['httpError' => 'Sent content not found in response!'], ]), ]); } } return $responses; } finally { $this->sentContentIds = []; } }
php
private function doSend() { try { if (!empty($this->sentContentIds) && count($this->sentContentIds) > $this->batchLimit) { throw new InvalidCallException(sprintf("Request limit reached! Max %d requests per batch is accepted!", $this->batchLimit)); } $response = $this->request->send(); $this->request = null; if ($response instanceof ApiResponse) { $response = [$response]; } $responses = []; $index = 0; foreach ($response as $_response) { $responses[$_response->id ?? $index] = $this->handleResponse($_response); $index++; } foreach ($this->sentContentIds as $sentContentId) { if (!array_key_exists($sentContentId, $responses)) { $responses[$sentContentId] = new ApiResponse([ 'success' => false, 'error' => new ResponseError([ 'type' => BadGatewayHttpException::class, 'code' => ResponseError::ERRORCODE_HTTP_RESPONSE_ERROR, 'message' => ['httpError' => 'Sent content not found in response!'], ]), ]); } } return $responses; } finally { $this->sentContentIds = []; } }
[ "private", "function", "doSend", "(", ")", "{", "try", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "sentContentIds", ")", "&&", "count", "(", "$", "this", "->", "sentContentIds", ")", ">", "$", "this", "->", "batchLimit", ")", "{", "throw",...
Sending deffered request. @return array @throws InvalidCallException
[ "Sending", "deffered", "request", "." ]
1988e3996dfdf7e17d1bd44d5d807f9884ac64bd
https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/auth/Client.php#L386-L419
train
thelia-modules/FeatureType
Model/Base/FeatureFeatureTypeQuery.php
FeatureFeatureTypeQuery.create
public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof \FeatureType\Model\FeatureFeatureTypeQuery) { return $criteria; } $query = new \FeatureType\Model\FeatureFeatureTypeQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
php
public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof \FeatureType\Model\FeatureFeatureTypeQuery) { return $criteria; } $query = new \FeatureType\Model\FeatureFeatureTypeQuery(); if (null !== $modelAlias) { $query->setModelAlias($modelAlias); } if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
[ "public", "static", "function", "create", "(", "$", "modelAlias", "=", "null", ",", "$", "criteria", "=", "null", ")", "{", "if", "(", "$", "criteria", "instanceof", "\\", "FeatureType", "\\", "Model", "\\", "FeatureFeatureTypeQuery", ")", "{", "return", "...
Returns a new ChildFeatureFeatureTypeQuery object. @param string $modelAlias The alias of a model in the query @param Criteria $criteria Optional Criteria to build the query from @return ChildFeatureFeatureTypeQuery
[ "Returns", "a", "new", "ChildFeatureFeatureTypeQuery", "object", "." ]
fc73eaaf53583758a316bb7e4af69ea50ec89997
https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureFeatureTypeQuery.php#L84-L98
train
thelia-modules/FeatureType
Model/Base/FeatureFeatureTypeQuery.php
FeatureFeatureTypeQuery.filterByFeatureId
public function filterByFeatureId($featureId = null, $comparison = null) { if (is_array($featureId)) { $useMinMax = false; if (isset($featureId['min'])) { $this->addUsingAlias(FeatureFeatureTypeTableMap::FEATURE_ID, $featureId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($featureId['max'])) { $this->addUsingAlias(FeatureFeatureTypeTableMap::FEATURE_ID, $featureId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(FeatureFeatureTypeTableMap::FEATURE_ID, $featureId, $comparison); }
php
public function filterByFeatureId($featureId = null, $comparison = null) { if (is_array($featureId)) { $useMinMax = false; if (isset($featureId['min'])) { $this->addUsingAlias(FeatureFeatureTypeTableMap::FEATURE_ID, $featureId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($featureId['max'])) { $this->addUsingAlias(FeatureFeatureTypeTableMap::FEATURE_ID, $featureId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(FeatureFeatureTypeTableMap::FEATURE_ID, $featureId, $comparison); }
[ "public", "function", "filterByFeatureId", "(", "$", "featureId", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "featureId", ")", ")", "{", "$", "useMinMax", "=", "false", ";", "if", "(", "isset", "(", "...
Filter the query on the feature_id column Example usage: <code> $query->filterByFeatureId(1234); // WHERE feature_id = 1234 $query->filterByFeatureId(array(12, 34)); // WHERE feature_id IN (12, 34) $query->filterByFeatureId(array('min' => 12)); // WHERE feature_id > 12 </code> @see filterByFeature() @param mixed $featureId The value to use as filter. Use scalar values for equality. Use array values for in_array() equivalent. Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildFeatureFeatureTypeQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "feature_id", "column" ]
fc73eaaf53583758a316bb7e4af69ea50ec89997
https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureFeatureTypeQuery.php#L297-L318
train
thelia-modules/FeatureType
Model/Base/FeatureFeatureTypeQuery.php
FeatureFeatureTypeQuery.filterByFeatureTypeId
public function filterByFeatureTypeId($featureTypeId = null, $comparison = null) { if (is_array($featureTypeId)) { $useMinMax = false; if (isset($featureTypeId['min'])) { $this->addUsingAlias(FeatureFeatureTypeTableMap::FEATURE_TYPE_ID, $featureTypeId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($featureTypeId['max'])) { $this->addUsingAlias(FeatureFeatureTypeTableMap::FEATURE_TYPE_ID, $featureTypeId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(FeatureFeatureTypeTableMap::FEATURE_TYPE_ID, $featureTypeId, $comparison); }
php
public function filterByFeatureTypeId($featureTypeId = null, $comparison = null) { if (is_array($featureTypeId)) { $useMinMax = false; if (isset($featureTypeId['min'])) { $this->addUsingAlias(FeatureFeatureTypeTableMap::FEATURE_TYPE_ID, $featureTypeId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($featureTypeId['max'])) { $this->addUsingAlias(FeatureFeatureTypeTableMap::FEATURE_TYPE_ID, $featureTypeId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(FeatureFeatureTypeTableMap::FEATURE_TYPE_ID, $featureTypeId, $comparison); }
[ "public", "function", "filterByFeatureTypeId", "(", "$", "featureTypeId", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "featureTypeId", ")", ")", "{", "$", "useMinMax", "=", "false", ";", "if", "(", "isset"...
Filter the query on the feature_type_id column Example usage: <code> $query->filterByFeatureTypeId(1234); // WHERE feature_type_id = 1234 $query->filterByFeatureTypeId(array(12, 34)); // WHERE feature_type_id IN (12, 34) $query->filterByFeatureTypeId(array('min' => 12)); // WHERE feature_type_id > 12 </code> @see filterByFeatureType() @param mixed $featureTypeId The value to use as filter. Use scalar values for equality. Use array values for in_array() equivalent. Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildFeatureFeatureTypeQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "feature_type_id", "column" ]
fc73eaaf53583758a316bb7e4af69ea50ec89997
https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureFeatureTypeQuery.php#L340-L361
train
thelia-modules/FeatureType
Model/Base/FeatureFeatureTypeQuery.php
FeatureFeatureTypeQuery.filterByFeature
public function filterByFeature($feature, $comparison = null) { if ($feature instanceof \Thelia\Model\Feature) { return $this ->addUsingAlias(FeatureFeatureTypeTableMap::FEATURE_ID, $feature->getId(), $comparison); } elseif ($feature instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this ->addUsingAlias(FeatureFeatureTypeTableMap::FEATURE_ID, $feature->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByFeature() only accepts arguments of type \Thelia\Model\Feature or Collection'); } }
php
public function filterByFeature($feature, $comparison = null) { if ($feature instanceof \Thelia\Model\Feature) { return $this ->addUsingAlias(FeatureFeatureTypeTableMap::FEATURE_ID, $feature->getId(), $comparison); } elseif ($feature instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this ->addUsingAlias(FeatureFeatureTypeTableMap::FEATURE_ID, $feature->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByFeature() only accepts arguments of type \Thelia\Model\Feature or Collection'); } }
[ "public", "function", "filterByFeature", "(", "$", "feature", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "$", "feature", "instanceof", "\\", "Thelia", "\\", "Model", "\\", "Feature", ")", "{", "return", "$", "this", "->", "addUsingAlias", ...
Filter the query by a related \Thelia\Model\Feature object @param \Thelia\Model\Feature|ObjectCollection $feature The related object(s) to use as filter @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildFeatureFeatureTypeQuery The current query, for fluid interface
[ "Filter", "the", "query", "by", "a", "related", "\\", "Thelia", "\\", "Model", "\\", "Feature", "object" ]
fc73eaaf53583758a316bb7e4af69ea50ec89997
https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureFeatureTypeQuery.php#L371-L386
train
thelia-modules/FeatureType
Model/Base/FeatureFeatureTypeQuery.php
FeatureFeatureTypeQuery.useFeatureQuery
public function useFeatureQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinFeature($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'Feature', '\Thelia\Model\FeatureQuery'); }
php
public function useFeatureQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinFeature($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'Feature', '\Thelia\Model\FeatureQuery'); }
[ "public", "function", "useFeatureQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "Criteria", "::", "INNER_JOIN", ")", "{", "return", "$", "this", "->", "joinFeature", "(", "$", "relationAlias", ",", "$", "joinType", ")", "->", "u...
Use the Feature relation Feature object @see useQuery() @param string $relationAlias optional alias for the relation, to be used as main alias in the secondary query @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' @return \Thelia\Model\FeatureQuery A secondary query class using the current class as primary query
[ "Use", "the", "Feature", "relation", "Feature", "object" ]
fc73eaaf53583758a316bb7e4af69ea50ec89997
https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureFeatureTypeQuery.php#L431-L436
train
thelia-modules/FeatureType
Model/Base/FeatureFeatureTypeQuery.php
FeatureFeatureTypeQuery.filterByFeatureTypeAvMeta
public function filterByFeatureTypeAvMeta($featureTypeAvMeta, $comparison = null) { if ($featureTypeAvMeta instanceof \FeatureType\Model\FeatureTypeAvMeta) { return $this ->addUsingAlias(FeatureFeatureTypeTableMap::ID, $featureTypeAvMeta->getFeatureFeatureTypeId(), $comparison); } elseif ($featureTypeAvMeta instanceof ObjectCollection) { return $this ->useFeatureTypeAvMetaQuery() ->filterByPrimaryKeys($featureTypeAvMeta->getPrimaryKeys()) ->endUse(); } else { throw new PropelException('filterByFeatureTypeAvMeta() only accepts arguments of type \FeatureType\Model\FeatureTypeAvMeta or Collection'); } }
php
public function filterByFeatureTypeAvMeta($featureTypeAvMeta, $comparison = null) { if ($featureTypeAvMeta instanceof \FeatureType\Model\FeatureTypeAvMeta) { return $this ->addUsingAlias(FeatureFeatureTypeTableMap::ID, $featureTypeAvMeta->getFeatureFeatureTypeId(), $comparison); } elseif ($featureTypeAvMeta instanceof ObjectCollection) { return $this ->useFeatureTypeAvMetaQuery() ->filterByPrimaryKeys($featureTypeAvMeta->getPrimaryKeys()) ->endUse(); } else { throw new PropelException('filterByFeatureTypeAvMeta() only accepts arguments of type \FeatureType\Model\FeatureTypeAvMeta or Collection'); } }
[ "public", "function", "filterByFeatureTypeAvMeta", "(", "$", "featureTypeAvMeta", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "$", "featureTypeAvMeta", "instanceof", "\\", "FeatureType", "\\", "Model", "\\", "FeatureTypeAvMeta", ")", "{", "return", ...
Filter the query by a related \FeatureType\Model\FeatureTypeAvMeta object @param \FeatureType\Model\FeatureTypeAvMeta|ObjectCollection $featureTypeAvMeta the related object to use as filter @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildFeatureFeatureTypeQuery The current query, for fluid interface
[ "Filter", "the", "query", "by", "a", "related", "\\", "FeatureType", "\\", "Model", "\\", "FeatureTypeAvMeta", "object" ]
fc73eaaf53583758a316bb7e4af69ea50ec89997
https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureFeatureTypeQuery.php#L521-L534
train
thelia-modules/FeatureType
Model/Base/FeatureFeatureTypeQuery.php
FeatureFeatureTypeQuery.useFeatureTypeAvMetaQuery
public function useFeatureTypeAvMetaQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinFeatureTypeAvMeta($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'FeatureTypeAvMeta', '\FeatureType\Model\FeatureTypeAvMetaQuery'); }
php
public function useFeatureTypeAvMetaQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinFeatureTypeAvMeta($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'FeatureTypeAvMeta', '\FeatureType\Model\FeatureTypeAvMetaQuery'); }
[ "public", "function", "useFeatureTypeAvMetaQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "Criteria", "::", "INNER_JOIN", ")", "{", "return", "$", "this", "->", "joinFeatureTypeAvMeta", "(", "$", "relationAlias", ",", "$", "joinType",...
Use the FeatureTypeAvMeta relation FeatureTypeAvMeta object @see useQuery() @param string $relationAlias optional alias for the relation, to be used as main alias in the secondary query @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' @return \FeatureType\Model\FeatureTypeAvMetaQuery A secondary query class using the current class as primary query
[ "Use", "the", "FeatureTypeAvMeta", "relation", "FeatureTypeAvMeta", "object" ]
fc73eaaf53583758a316bb7e4af69ea50ec89997
https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureFeatureTypeQuery.php#L579-L584
train
neo-framework/neo-core
src/neo/core/router/Router.php
Router.map
public function map($method, string $route, string $action, string $controller) { // alias $proxy = $this->proxy_factory; if (!\is_array($method)) { $method = [(string)$method]; } // whitelist http methods \array_walk($method, function ($v) { if (!\in_array($v, ['GET', 'POST', 'PUT', 'DELETE'])) { throw new \InvalidArgumentException(\sprintf('Unknown http method: "%s"', $v)); } }); foreach ($method as $m) { $this->klein->respond($m, $route, function ($request, $response) use (&$proxy, $action, $controller) { return $proxy($controller) ->setRequest($request) ->setResponse($response) ->$action(); }); } return $this; }
php
public function map($method, string $route, string $action, string $controller) { // alias $proxy = $this->proxy_factory; if (!\is_array($method)) { $method = [(string)$method]; } // whitelist http methods \array_walk($method, function ($v) { if (!\in_array($v, ['GET', 'POST', 'PUT', 'DELETE'])) { throw new \InvalidArgumentException(\sprintf('Unknown http method: "%s"', $v)); } }); foreach ($method as $m) { $this->klein->respond($m, $route, function ($request, $response) use (&$proxy, $action, $controller) { return $proxy($controller) ->setRequest($request) ->setResponse($response) ->$action(); }); } return $this; }
[ "public", "function", "map", "(", "$", "method", ",", "string", "$", "route", ",", "string", "$", "action", ",", "string", "$", "controller", ")", "{", "// alias", "$", "proxy", "=", "$", "this", "->", "proxy_factory", ";", "if", "(", "!", "\\", "is_...
Map HTTP method and route to some action and controller. @param mixed $method Uppercase HTTP method string or array of multiple methods. @param string $route Concrete route or route pattern. @param string $action Name of the action method that shall be called if route gets matched. @param string $controller Fully qualified class name of the {@link Controller} that shall be invoked.
[ "Map", "HTTP", "method", "and", "route", "to", "some", "action", "and", "controller", "." ]
6bcd0982a6c7fac652180ae2c6aae7a99fd90d67
https://github.com/neo-framework/neo-core/blob/6bcd0982a6c7fac652180ae2c6aae7a99fd90d67/src/neo/core/router/Router.php#L43-L71
train
neo-framework/neo-core
src/neo/core/router/Router.php
Router.dispatch
public function dispatch(Request $request, ControllerFactory $actual_factory) { $this->proxy_factory ->replace($actual_factory) ->close(); $this->klein->dispatch($request); }
php
public function dispatch(Request $request, ControllerFactory $actual_factory) { $this->proxy_factory ->replace($actual_factory) ->close(); $this->klein->dispatch($request); }
[ "public", "function", "dispatch", "(", "Request", "$", "request", ",", "ControllerFactory", "$", "actual_factory", ")", "{", "$", "this", "->", "proxy_factory", "->", "replace", "(", "$", "actual_factory", ")", "->", "close", "(", ")", ";", "$", "this", "-...
Dispatch request.
[ "Dispatch", "request", "." ]
6bcd0982a6c7fac652180ae2c6aae7a99fd90d67
https://github.com/neo-framework/neo-core/blob/6bcd0982a6c7fac652180ae2c6aae7a99fd90d67/src/neo/core/router/Router.php#L76-L83
train
digbang/security
src/SecurityContext.php
SecurityContext.add
public function add(SecurityContextConfiguration $configuration) { $this->contexts[$configuration->getName()] = $configuration; $this->updateMappings( $configuration, $this->container->make(EntityManagerInterface::class) ); }
php
public function add(SecurityContextConfiguration $configuration) { $this->contexts[$configuration->getName()] = $configuration; $this->updateMappings( $configuration, $this->container->make(EntityManagerInterface::class) ); }
[ "public", "function", "add", "(", "SecurityContextConfiguration", "$", "configuration", ")", "{", "$", "this", "->", "contexts", "[", "$", "configuration", "->", "getName", "(", ")", "]", "=", "$", "configuration", ";", "$", "this", "->", "updateMappings", "...
Add a security context. @param SecurityContextConfiguration $configuration @throws \BadMethodCallException
[ "Add", "a", "security", "context", "." ]
ee925c5a144a1553f5a72ded6f5a66c01a86ab21
https://github.com/digbang/security/blob/ee925c5a144a1553f5a72ded6f5a66c01a86ab21/src/SecurityContext.php#L61-L69
train
digbang/security
src/SecurityContext.php
SecurityContext.bindContext
public function bindContext($context, Request $request) { $security = $this->getSecurity($context); $this->container->instance(SecurityApi::class, $security); $this->container->bind(UrlGeneratorContract::class, function() use ($security){ return $security->url(); }); $this->container->bind(UrlGenerator::class, function(Container $container) use ($security){ /** @var PermissionAwareUrlGeneratorExtension $url */ $url = $container->make(PermissionAwareUrlGeneratorExtension::class); $url->setUrlGenerator($security->url()); return $url; }); $this->container->alias(UrlGenerator::class, 'url'); $request->setUserResolver(function() use ($security){ return $security->getUser(); }); }
php
public function bindContext($context, Request $request) { $security = $this->getSecurity($context); $this->container->instance(SecurityApi::class, $security); $this->container->bind(UrlGeneratorContract::class, function() use ($security){ return $security->url(); }); $this->container->bind(UrlGenerator::class, function(Container $container) use ($security){ /** @var PermissionAwareUrlGeneratorExtension $url */ $url = $container->make(PermissionAwareUrlGeneratorExtension::class); $url->setUrlGenerator($security->url()); return $url; }); $this->container->alias(UrlGenerator::class, 'url'); $request->setUserResolver(function() use ($security){ return $security->getUser(); }); }
[ "public", "function", "bindContext", "(", "$", "context", ",", "Request", "$", "request", ")", "{", "$", "security", "=", "$", "this", "->", "getSecurity", "(", "$", "context", ")", ";", "$", "this", "->", "container", "->", "instance", "(", "SecurityApi...
Bind the given security context to the Request and Container. @param string $context @param Request $request
[ "Bind", "the", "given", "security", "context", "to", "the", "Request", "and", "Container", "." ]
ee925c5a144a1553f5a72ded6f5a66c01a86ab21
https://github.com/digbang/security/blob/ee925c5a144a1553f5a72ded6f5a66c01a86ab21/src/SecurityContext.php#L77-L100
train
digbang/security
src/SecurityContext.php
SecurityContext.getSecurity
public function getSecurity($context) { if (array_key_exists($context, $this->instances)) { return $this->instances[$context]; } $configuration = $this->getConfigurationFor($context); $this->addPermissionsFactoryListener($context); return $this->instances[$context] = $this->getSecurityFactory()->create($context, $configuration); }
php
public function getSecurity($context) { if (array_key_exists($context, $this->instances)) { return $this->instances[$context]; } $configuration = $this->getConfigurationFor($context); $this->addPermissionsFactoryListener($context); return $this->instances[$context] = $this->getSecurityFactory()->create($context, $configuration); }
[ "public", "function", "getSecurity", "(", "$", "context", ")", "{", "if", "(", "array_key_exists", "(", "$", "context", ",", "$", "this", "->", "instances", ")", ")", "{", "return", "$", "this", "->", "instances", "[", "$", "context", "]", ";", "}", ...
Get the Security instance for the given context. @param string $context @return Security
[ "Get", "the", "Security", "instance", "for", "the", "given", "context", "." ]
ee925c5a144a1553f5a72ded6f5a66c01a86ab21
https://github.com/digbang/security/blob/ee925c5a144a1553f5a72ded6f5a66c01a86ab21/src/SecurityContext.php#L108-L119
train
davedevelopment/dspec
src/DSpec/ExampleGroup.php
ExampleGroup.runHooks
public function runHooks($name, AbstractContext $context, $reverse = false) { $parent = $this->getParent(); $hooks = $this->hooks[$name]; if ($reverse) { foreach (array_reverse($hooks) as $hook) { $hook->run($context); } if ($parent) { $parent->runHooks($name, $context, $reverse); } } else { if ($parent) { $parent->runHooks($name, $context, $reverse); } foreach ($hooks as $hook) { $hook->run($context); } } }
php
public function runHooks($name, AbstractContext $context, $reverse = false) { $parent = $this->getParent(); $hooks = $this->hooks[$name]; if ($reverse) { foreach (array_reverse($hooks) as $hook) { $hook->run($context); } if ($parent) { $parent->runHooks($name, $context, $reverse); } } else { if ($parent) { $parent->runHooks($name, $context, $reverse); } foreach ($hooks as $hook) { $hook->run($context); } } }
[ "public", "function", "runHooks", "(", "$", "name", ",", "AbstractContext", "$", "context", ",", "$", "reverse", "=", "false", ")", "{", "$", "parent", "=", "$", "this", "->", "getParent", "(", ")", ";", "$", "hooks", "=", "$", "this", "->", "hooks",...
Traverse ancestry running hooks @param string $name
[ "Traverse", "ancestry", "running", "hooks" ]
6077b1d213dc09f1fbcf7b260f3926a7019a0618
https://github.com/davedevelopment/dspec/blob/6077b1d213dc09f1fbcf7b260f3926a7019a0618/src/DSpec/ExampleGroup.php#L82-L102
train
davedevelopment/dspec
src/DSpec/ExampleGroup.php
ExampleGroup.total
public function total() { $total = array_reduce($this->examples, function($x, $e) { $x += $e instanceof Example ? 1 : $e->total(); return $x; }, 0); return $total; }
php
public function total() { $total = array_reduce($this->examples, function($x, $e) { $x += $e instanceof Example ? 1 : $e->total(); return $x; }, 0); return $total; }
[ "public", "function", "total", "(", ")", "{", "$", "total", "=", "array_reduce", "(", "$", "this", "->", "examples", ",", "function", "(", "$", "x", ",", "$", "e", ")", "{", "$", "x", "+=", "$", "e", "instanceof", "Example", "?", "1", ":", "$", ...
Get total number of tests @return int
[ "Get", "total", "number", "of", "tests" ]
6077b1d213dc09f1fbcf7b260f3926a7019a0618
https://github.com/davedevelopment/dspec/blob/6077b1d213dc09f1fbcf7b260f3926a7019a0618/src/DSpec/ExampleGroup.php#L126-L134
train
davedevelopment/dspec
src/DSpec/ExampleGroup.php
ExampleGroup.setErrorHandler
public function setErrorHandler() { set_error_handler(function ($errno, $errstr, $errfile, $errline ) { throw new \ErrorException($errstr, 0, $errno, $errfile, $errline); }); }
php
public function setErrorHandler() { set_error_handler(function ($errno, $errstr, $errfile, $errline ) { throw new \ErrorException($errstr, 0, $errno, $errfile, $errline); }); }
[ "public", "function", "setErrorHandler", "(", ")", "{", "set_error_handler", "(", "function", "(", "$", "errno", ",", "$", "errstr", ",", "$", "errfile", ",", "$", "errline", ")", "{", "throw", "new", "\\", "ErrorException", "(", "$", "errstr", ",", "0",...
Set error handler
[ "Set", "error", "handler" ]
6077b1d213dc09f1fbcf7b260f3926a7019a0618
https://github.com/davedevelopment/dspec/blob/6077b1d213dc09f1fbcf7b260f3926a7019a0618/src/DSpec/ExampleGroup.php#L200-L205
train
mylukin/pscws4
src/PSCWS4.php
PSCWS4._rule_get
function _rule_get($str) { if (!isset($this->_rd[$str])) return false; return $this->_rd[$str]; }
php
function _rule_get($str) { if (!isset($this->_rd[$str])) return false; return $this->_rd[$str]; }
[ "function", "_rule_get", "(", "$", "str", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_rd", "[", "$", "str", "]", ")", ")", "return", "false", ";", "return", "$", "this", "->", "_rd", "[", "$", "str", "]", ";", "}" ]
get the ruleset
[ "get", "the", "ruleset" ]
b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b
https://github.com/mylukin/pscws4/blob/b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b/src/PSCWS4.php#L446-L449
train
mylukin/pscws4
src/PSCWS4.php
PSCWS4._rule_checkbit
function _rule_checkbit($str, $bit) { if (!isset($this->_rd[$str])) return false; $bit2 = $this->_rd[$str]['bit']; return ($bit & $bit2 ? true : false); }
php
function _rule_checkbit($str, $bit) { if (!isset($this->_rd[$str])) return false; $bit2 = $this->_rd[$str]['bit']; return ($bit & $bit2 ? true : false); }
[ "function", "_rule_checkbit", "(", "$", "str", ",", "$", "bit", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_rd", "[", "$", "str", "]", ")", ")", "return", "false", ";", "$", "bit2", "=", "$", "this", "->", "_rd", "[", "$", "s...
check the bit with str
[ "check", "the", "bit", "with", "str" ]
b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b
https://github.com/mylukin/pscws4/blob/b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b/src/PSCWS4.php#L452-L456
train
mylukin/pscws4
src/PSCWS4.php
PSCWS4._rule_check
function _rule_check($rule, $str) { if (($rule['flag'] & PSCWS4_ZRULE_INCLUDE) && !$this->_rule_checkbit($str, $rule['bit'])) return false; if (($rule['flag'] & PSCWS4_ZRULE_EXCLUDE) && $this->_rule_checkbit($str, $rule['bit'])) return false; return true; }
php
function _rule_check($rule, $str) { if (($rule['flag'] & PSCWS4_ZRULE_INCLUDE) && !$this->_rule_checkbit($str, $rule['bit'])) return false; if (($rule['flag'] & PSCWS4_ZRULE_EXCLUDE) && $this->_rule_checkbit($str, $rule['bit'])) return false; return true; }
[ "function", "_rule_check", "(", "$", "rule", ",", "$", "str", ")", "{", "if", "(", "(", "$", "rule", "[", "'flag'", "]", "&", "PSCWS4_ZRULE_INCLUDE", ")", "&&", "!", "$", "this", "->", "_rule_checkbit", "(", "$", "str", ",", "$", "rule", "[", "'bit...
check the rule include | exclude
[ "check", "the", "rule", "include", "|", "exclude" ]
b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b
https://github.com/mylukin/pscws4/blob/b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b/src/PSCWS4.php#L459-L465
train
mylukin/pscws4
src/PSCWS4.php
PSCWS4._dict_query
function _dict_query($word) { if (!$this->_xd) return false; $value = $this->_xd->Get($word); if (!$value) return false; $tmp = unpack('ftf/fidf/Cflag/a3attr', $value); return $tmp; }
php
function _dict_query($word) { if (!$this->_xd) return false; $value = $this->_xd->Get($word); if (!$value) return false; $tmp = unpack('ftf/fidf/Cflag/a3attr', $value); return $tmp; }
[ "function", "_dict_query", "(", "$", "word", ")", "{", "if", "(", "!", "$", "this", "->", "_xd", ")", "return", "false", ";", "$", "value", "=", "$", "this", "->", "_xd", "->", "Get", "(", "$", "word", ")", ";", "if", "(", "!", "$", "value", ...
query the dict
[ "query", "the", "dict" ]
b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b
https://github.com/mylukin/pscws4/blob/b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b/src/PSCWS4.php#L505-L511
train
mylukin/pscws4
src/PSCWS4.php
PSCWS4._get_zs
function _get_zs($i, $j = -1) { if ($j == -1) $j = $i; return substr($this->_txt, $this->_zmap[$i]['start'], $this->_zmap[$j]['end'] - $this->_zmap[$i]['start']); }
php
function _get_zs($i, $j = -1) { if ($j == -1) $j = $i; return substr($this->_txt, $this->_zmap[$i]['start'], $this->_zmap[$j]['end'] - $this->_zmap[$i]['start']); }
[ "function", "_get_zs", "(", "$", "i", ",", "$", "j", "=", "-", "1", ")", "{", "if", "(", "$", "j", "==", "-", "1", ")", "$", "j", "=", "$", "i", ";", "return", "substr", "(", "$", "this", "->", "_txt", ",", "$", "this", "->", "_zmap", "["...
get one z by ZMAP
[ "get", "one", "z", "by", "ZMAP" ]
b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b
https://github.com/mylukin/pscws4/blob/b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b/src/PSCWS4.php#L572-L575
train
aimeos/ai-fosuser
lib/custom/src/MShop/Customer/Item/FosUser.php
FosUser.setSalt
public function setSalt( $value ) { if( (string) $value !== $this->getSalt() ) { $this->values['salt'] = (string) $value; $this->setModified(); } return $this; }
php
public function setSalt( $value ) { if( (string) $value !== $this->getSalt() ) { $this->values['salt'] = (string) $value; $this->setModified(); } return $this; }
[ "public", "function", "setSalt", "(", "$", "value", ")", "{", "if", "(", "(", "string", ")", "$", "value", "!==", "$", "this", "->", "getSalt", "(", ")", ")", "{", "$", "this", "->", "values", "[", "'salt'", "]", "=", "(", "string", ")", "$", "...
Sets the password salt @param string $value Password salt
[ "Sets", "the", "password", "salt" ]
80eec0d0c0e0ef4556b4cd96ca88c993179e0c6f
https://github.com/aimeos/ai-fosuser/blob/80eec0d0c0e0ef4556b4cd96ca88c993179e0c6f/lib/custom/src/MShop/Customer/Item/FosUser.php#L136-L145
train
koolkode/async
src/DNS/ResponseParser.php
ResponseParser.parse
public function parse(Context $context, ?Request $request = null): \Generator { $header = \unpack('nid/nflags/nqc/nac/nauth/nadd', yield $this->stream->readBuffer($context, 12)); $this->offset += 12; $response = new Response($header['id']); $response->setFlags($header['flags']); if ($request && $response->getId() !== $request->getId()) { throw new \RuntimeException(\sprintf('Expected DNS message ID is %u, server returned %u', $request->getId(), $response->getId())); } $response->setAuthorityCount($header['auth']); $response->setAdditionalCount($header['add']); // Parse questions: for ($i = 0; $i < $header['qc']; $i++) { yield from $this->parseQuestion($context, $response); } if ($request && $response->getQuestions() !== $request->getQuestions()) { throw new \RuntimeException('DNS server did not return the question(s) in the response message'); } // Parse answers: for ($i = 0; $i < $header['ac']; $i++) { yield from $this->parseAnswer($context, $response); } return $response; }
php
public function parse(Context $context, ?Request $request = null): \Generator { $header = \unpack('nid/nflags/nqc/nac/nauth/nadd', yield $this->stream->readBuffer($context, 12)); $this->offset += 12; $response = new Response($header['id']); $response->setFlags($header['flags']); if ($request && $response->getId() !== $request->getId()) { throw new \RuntimeException(\sprintf('Expected DNS message ID is %u, server returned %u', $request->getId(), $response->getId())); } $response->setAuthorityCount($header['auth']); $response->setAdditionalCount($header['add']); // Parse questions: for ($i = 0; $i < $header['qc']; $i++) { yield from $this->parseQuestion($context, $response); } if ($request && $response->getQuestions() !== $request->getQuestions()) { throw new \RuntimeException('DNS server did not return the question(s) in the response message'); } // Parse answers: for ($i = 0; $i < $header['ac']; $i++) { yield from $this->parseAnswer($context, $response); } return $response; }
[ "public", "function", "parse", "(", "Context", "$", "context", ",", "?", "Request", "$", "request", "=", "null", ")", ":", "\\", "Generator", "{", "$", "header", "=", "\\", "unpack", "(", "'nid/nflags/nqc/nac/nauth/nadd'", ",", "yield", "$", "this", "->", ...
Read and parse a DNS response message. @param Context $context Async execution context. @param Request $request DNS request that has been sent. @return Response Validated DNS response received from the server.
[ "Read", "and", "parse", "a", "DNS", "response", "message", "." ]
9c985dcdd3b328323826dd4254d9f2e5aea0b75b
https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/DNS/ResponseParser.php#L62-L92
train
koolkode/async
src/DNS/ResponseParser.php
ResponseParser.parseQuestion
protected function parseQuestion(Context $context, Response $response): \Generator { $host = yield from $this->readLabel($context); $question = \unpack('ntype/nclass', yield $this->stream->readBuffer($context, 4)); $this->offset += 4; $response->addQuestion($host, $question['type'], $question['class']); }
php
protected function parseQuestion(Context $context, Response $response): \Generator { $host = yield from $this->readLabel($context); $question = \unpack('ntype/nclass', yield $this->stream->readBuffer($context, 4)); $this->offset += 4; $response->addQuestion($host, $question['type'], $question['class']); }
[ "protected", "function", "parseQuestion", "(", "Context", "$", "context", ",", "Response", "$", "response", ")", ":", "\\", "Generator", "{", "$", "host", "=", "yield", "from", "$", "this", "->", "readLabel", "(", "$", "context", ")", ";", "$", "question...
Parse a DNS question record and add it the given response. @param Context $context Async execution context. @param Response $response DNS response object.
[ "Parse", "a", "DNS", "question", "record", "and", "add", "it", "the", "given", "response", "." ]
9c985dcdd3b328323826dd4254d9f2e5aea0b75b
https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/DNS/ResponseParser.php#L100-L108
train
koolkode/async
src/DNS/ResponseParser.php
ResponseParser.parseAnswer
protected function parseAnswer(Context $context, Response $response): \Generator { $host = yield from $this->readLabel($context); $answer = \unpack('ntype/nclass/Nttl/nlen', yield $this->stream->readBuffer($context, 10)); $this->offset += 10; $ttl = $answer['ttl']; $len = $answer['len']; // Discard payloads of truncated messages. if ($response->isTruncated()) { $data = yield $this->stream->readBuffer($context, $len); $this->offset += $len; return; } switch ($answer['type']) { case Message::TYPE_A: case Message::TYPE_AAAA: $data = \inet_ntop(yield $this->stream->readBuffer($context, $len)); $this->offset += $len; break; case Message::TYPE_CNAME: $data = yield from $this->readLabel($context); break; default: $data = yield $this->stream->readBuffer($context, $len); $this->offset += $len; } if ($ttl & 0x80000000) { $ttl = ($ttl - 0xFFFFFFFF); } $response->addAnswer($host, $answer['type'], $answer['class'], $data, $ttl); }
php
protected function parseAnswer(Context $context, Response $response): \Generator { $host = yield from $this->readLabel($context); $answer = \unpack('ntype/nclass/Nttl/nlen', yield $this->stream->readBuffer($context, 10)); $this->offset += 10; $ttl = $answer['ttl']; $len = $answer['len']; // Discard payloads of truncated messages. if ($response->isTruncated()) { $data = yield $this->stream->readBuffer($context, $len); $this->offset += $len; return; } switch ($answer['type']) { case Message::TYPE_A: case Message::TYPE_AAAA: $data = \inet_ntop(yield $this->stream->readBuffer($context, $len)); $this->offset += $len; break; case Message::TYPE_CNAME: $data = yield from $this->readLabel($context); break; default: $data = yield $this->stream->readBuffer($context, $len); $this->offset += $len; } if ($ttl & 0x80000000) { $ttl = ($ttl - 0xFFFFFFFF); } $response->addAnswer($host, $answer['type'], $answer['class'], $data, $ttl); }
[ "protected", "function", "parseAnswer", "(", "Context", "$", "context", ",", "Response", "$", "response", ")", ":", "\\", "Generator", "{", "$", "host", "=", "yield", "from", "$", "this", "->", "readLabel", "(", "$", "context", ")", ";", "$", "answer", ...
Parse a DNS answer record and add it to the given response. @param Context $context Async execution context. @param Response $response DNS response object.
[ "Parse", "a", "DNS", "answer", "record", "and", "add", "it", "to", "the", "given", "response", "." ]
9c985dcdd3b328323826dd4254d9f2e5aea0b75b
https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/DNS/ResponseParser.php#L116-L153
train
phug-php/lexer
src/Phug/Lexer/State.php
State.nextOutdent
public function nextOutdent() { $oldLevel = $this->getIndentLevel(); $expected = $this->getLevel(); if ($expected < $oldLevel) { $newLevel = $this->outdent(); if ($newLevel < $expected) { $this->throwException( 'Inconsistent indentation. '. 'Expecting either '. $newLevel. ' or '. $oldLevel. ' spaces/tabs.' ); } return $newLevel; } return false; }
php
public function nextOutdent() { $oldLevel = $this->getIndentLevel(); $expected = $this->getLevel(); if ($expected < $oldLevel) { $newLevel = $this->outdent(); if ($newLevel < $expected) { $this->throwException( 'Inconsistent indentation. '. 'Expecting either '. $newLevel. ' or '. $oldLevel. ' spaces/tabs.' ); } return $newLevel; } return false; }
[ "public", "function", "nextOutdent", "(", ")", "{", "$", "oldLevel", "=", "$", "this", "->", "getIndentLevel", "(", ")", ";", "$", "expected", "=", "$", "this", "->", "getLevel", "(", ")", ";", "if", "(", "$", "expected", "<", "$", "oldLevel", ")", ...
Return new outdent level if current above expected, or false if expected level reached. @return int
[ "Return", "new", "outdent", "level", "if", "current", "above", "expected", "or", "false", "if", "expected", "level", "reached", "." ]
63d8876899168b136cf27304c2d888f0f7fe3414
https://github.com/phug-php/lexer/blob/63d8876899168b136cf27304c2d888f0f7fe3414/src/Phug/Lexer/State.php#L164-L186
train
phug-php/lexer
src/Phug/Lexer/State.php
State.indent
public function indent($level = null) { $level = $level ?: $this->getLevel(); array_push($this->indentStack, $level); return $level; }
php
public function indent($level = null) { $level = $level ?: $this->getLevel(); array_push($this->indentStack, $level); return $level; }
[ "public", "function", "indent", "(", "$", "level", "=", "null", ")", "{", "$", "level", "=", "$", "level", "?", ":", "$", "this", "->", "getLevel", "(", ")", ";", "array_push", "(", "$", "this", "->", "indentStack", ",", "$", "level", ")", ";", "...
Indent and return the new level. @param null $level @return int
[ "Indent", "and", "return", "the", "new", "level", "." ]
63d8876899168b136cf27304c2d888f0f7fe3414
https://github.com/phug-php/lexer/blob/63d8876899168b136cf27304c2d888f0f7fe3414/src/Phug/Lexer/State.php#L195-L201
train
phug-php/lexer
src/Phug/Lexer/State.php
State.scan
public function scan($scanners) { $scanners = $this->filterScanners($scanners); foreach ($scanners as $key => $scanner) { /** @var ScannerInterface $scanner */ $success = false; foreach ($scanner->scan($this) as $token) { if (!($token instanceof TokenInterface)) { $this->throwException( 'Scanner '.get_class($scanner).' generated a result that is not a '.TokenInterface::class ); } yield $token; $success = true; } if ($success) { return; } } }
php
public function scan($scanners) { $scanners = $this->filterScanners($scanners); foreach ($scanners as $key => $scanner) { /** @var ScannerInterface $scanner */ $success = false; foreach ($scanner->scan($this) as $token) { if (!($token instanceof TokenInterface)) { $this->throwException( 'Scanner '.get_class($scanner).' generated a result that is not a '.TokenInterface::class ); } yield $token; $success = true; } if ($success) { return; } } }
[ "public", "function", "scan", "(", "$", "scanners", ")", "{", "$", "scanners", "=", "$", "this", "->", "filterScanners", "(", "$", "scanners", ")", ";", "foreach", "(", "$", "scanners", "as", "$", "key", "=>", "$", "scanner", ")", "{", "/** @var Scanne...
Runs all passed scanners once on the input string. The first scan that returns valid tokens will stop the scanning and yields these tokens. If you want to continuously scan on something, rather use the `loopScan`-method @param array|string $scanners the scanners to run @throws LexerException @return \Generator the generator yielding all tokens found
[ "Runs", "all", "passed", "scanners", "once", "on", "the", "input", "string", "." ]
63d8876899168b136cf27304c2d888f0f7fe3414
https://github.com/phug-php/lexer/blob/63d8876899168b136cf27304c2d888f0f7fe3414/src/Phug/Lexer/State.php#L216-L239
train
phug-php/lexer
src/Phug/Lexer/State.php
State.loopScan
public function loopScan($scanners, $required = false) { while ($this->reader->hasLength()) { $success = false; foreach ($this->scan($scanners) as $token) { $success = true; yield $token; } if (!$success) { break; } } if ($this->reader->hasLength() && $required) { $this->throwException( 'Unexpected '.$this->reader->peek(20) ); } }
php
public function loopScan($scanners, $required = false) { while ($this->reader->hasLength()) { $success = false; foreach ($this->scan($scanners) as $token) { $success = true; yield $token; } if (!$success) { break; } } if ($this->reader->hasLength() && $required) { $this->throwException( 'Unexpected '.$this->reader->peek(20) ); } }
[ "public", "function", "loopScan", "(", "$", "scanners", ",", "$", "required", "=", "false", ")", "{", "while", "(", "$", "this", "->", "reader", "->", "hasLength", "(", ")", ")", "{", "$", "success", "=", "false", ";", "foreach", "(", "$", "this", ...
Continuously scans with all scanners passed as the first argument. If the second argument is true, it will throw an exception if none of the scanners produced any valid tokens. The reading also stops when the end of the input as been reached. @param $scanners @param bool $required @throws LexerException @return \Generator
[ "Continuously", "scans", "with", "all", "scanners", "passed", "as", "the", "first", "argument", "." ]
63d8876899168b136cf27304c2d888f0f7fe3414
https://github.com/phug-php/lexer/blob/63d8876899168b136cf27304c2d888f0f7fe3414/src/Phug/Lexer/State.php#L254-L273
train
phug-php/lexer
src/Phug/Lexer/State.php
State.createToken
public function createToken($className) { if (!is_subclass_of($className, TokenInterface::class)) { $this->throwException( "$className is not a valid token sub-class" ); } return new $className( $this->createCurrentSourceLocation(), $this->level, str_repeat($this->getIndentStyle(), $this->getIndentWidth()) ); }
php
public function createToken($className) { if (!is_subclass_of($className, TokenInterface::class)) { $this->throwException( "$className is not a valid token sub-class" ); } return new $className( $this->createCurrentSourceLocation(), $this->level, str_repeat($this->getIndentStyle(), $this->getIndentWidth()) ); }
[ "public", "function", "createToken", "(", "$", "className", ")", "{", "if", "(", "!", "is_subclass_of", "(", "$", "className", ",", "TokenInterface", "::", "class", ")", ")", "{", "$", "this", "->", "throwException", "(", "\"$className is not a valid token sub-c...
Creates a new instance of a token. The token automatically receives line/offset/level information through this method. @param string $className the class name of the token @return TokenInterface the token
[ "Creates", "a", "new", "instance", "of", "a", "token", "." ]
63d8876899168b136cf27304c2d888f0f7fe3414
https://github.com/phug-php/lexer/blob/63d8876899168b136cf27304c2d888f0f7fe3414/src/Phug/Lexer/State.php#L293-L306
train
phug-php/lexer
src/Phug/Lexer/State.php
State.scanToken
public function scanToken($className, $pattern, $modifiers = null) { if (!$this->reader->match($pattern, $modifiers)) { return; } $data = $this->reader->getMatchData(); $token = $this->createToken($className); $this->reader->consume(); foreach ($data as $key => $value) { $method = 'set'.ucfirst($key); if (method_exists($token, $method)) { call_user_func([$token, $method], $value); } } yield $this->endToken($token); }
php
public function scanToken($className, $pattern, $modifiers = null) { if (!$this->reader->match($pattern, $modifiers)) { return; } $data = $this->reader->getMatchData(); $token = $this->createToken($className); $this->reader->consume(); foreach ($data as $key => $value) { $method = 'set'.ucfirst($key); if (method_exists($token, $method)) { call_user_func([$token, $method], $value); } } yield $this->endToken($token); }
[ "public", "function", "scanToken", "(", "$", "className", ",", "$", "pattern", ",", "$", "modifiers", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "reader", "->", "match", "(", "$", "pattern", ",", "$", "modifiers", ")", ")", "{", "ret...
Quickly scans for a token by a single regular expression pattern. If the pattern matches, this method will yield a new token. If not, it will yield nothing All named capture groups are converted to `set*()`-methods, e.g. `(?:<name>[a-z]+)` will automatically call `setName(<matchedValue>)` on the token. This method could be written without generators, but the way its designed is easier to use in scanners as you can simply return it's value without having to check for it to be null. @param $className @param $pattern @param null $modifiers @return \Generator
[ "Quickly", "scans", "for", "a", "token", "by", "a", "single", "regular", "expression", "pattern", "." ]
63d8876899168b136cf27304c2d888f0f7fe3414
https://github.com/phug-php/lexer/blob/63d8876899168b136cf27304c2d888f0f7fe3414/src/Phug/Lexer/State.php#L326-L345
train
phug-php/lexer
src/Phug/Lexer/State.php
State.filterScanners
private function filterScanners($scanners) { $scannerInstances = []; $scanners = is_array($scanners) ? $scanners : [$scanners]; foreach ($scanners as $key => $scanner) { if (!is_a($scanner, ScannerInterface::class, true)) { throw new \InvalidArgumentException( "The passed scanner with key `$key` doesn't seem to be either a valid ".ScannerInterface::class. ' instance or extended class' ); } $scannerInstances[] = $scanner instanceof ScannerInterface ? $scanner : new $scanner(); } return $scannerInstances; }
php
private function filterScanners($scanners) { $scannerInstances = []; $scanners = is_array($scanners) ? $scanners : [$scanners]; foreach ($scanners as $key => $scanner) { if (!is_a($scanner, ScannerInterface::class, true)) { throw new \InvalidArgumentException( "The passed scanner with key `$key` doesn't seem to be either a valid ".ScannerInterface::class. ' instance or extended class' ); } $scannerInstances[] = $scanner instanceof ScannerInterface ? $scanner : new $scanner(); } return $scannerInstances; }
[ "private", "function", "filterScanners", "(", "$", "scanners", ")", "{", "$", "scannerInstances", "=", "[", "]", ";", "$", "scanners", "=", "is_array", "(", "$", "scanners", ")", "?", "$", "scanners", ":", "[", "$", "scanners", "]", ";", "foreach", "("...
Filters and validates the passed scanners. This method makes sure that all scanners given are turned into their respective instances. @param $scanners @return array
[ "Filters", "and", "validates", "the", "passed", "scanners", "." ]
63d8876899168b136cf27304c2d888f0f7fe3414
https://github.com/phug-php/lexer/blob/63d8876899168b136cf27304c2d888f0f7fe3414/src/Phug/Lexer/State.php#L370-L388
train
meritoo/common-bundle
src/Service/ResponseService.php
ResponseService.getRedirectResponse
public function getRedirectResponse(string $routeName, array $routeParameters = []): RedirectResponse { $url = $this->router->generate($routeName, $routeParameters); return new RedirectResponse($url); }
php
public function getRedirectResponse(string $routeName, array $routeParameters = []): RedirectResponse { $url = $this->router->generate($routeName, $routeParameters); return new RedirectResponse($url); }
[ "public", "function", "getRedirectResponse", "(", "string", "$", "routeName", ",", "array", "$", "routeParameters", "=", "[", "]", ")", ":", "RedirectResponse", "{", "$", "url", "=", "$", "this", "->", "router", "->", "generate", "(", "$", "routeName", ","...
Returns the "redirect response" that is used to redirect to url generated by given route and parameters @param string $routeName The name of the route. Used to build url used for redirection. @param array $routeParameters (optional) An array of parameters. Used to build url used for redirection. @return RedirectResponse
[ "Returns", "the", "redirect", "response", "that", "is", "used", "to", "redirect", "to", "url", "generated", "by", "given", "route", "and", "parameters" ]
560c3a6c14fce2e17208261b8c606f6208f44e23
https://github.com/meritoo/common-bundle/blob/560c3a6c14fce2e17208261b8c606f6208f44e23/src/Service/ResponseService.php#L49-L54
train
teepluss/laravel4-categorize
src/Teepluss/Categorize/CategorizeServiceProvider.php
CategorizeServiceProvider.registerCategoryProvider
protected function registerCategoryProvider() { $this->app['categorize.category'] = $this->app->share(function($app) { $model = $app['config']->get('categorize::categories.model'); return new CategoryProvider($model); }); }
php
protected function registerCategoryProvider() { $this->app['categorize.category'] = $this->app->share(function($app) { $model = $app['config']->get('categorize::categories.model'); return new CategoryProvider($model); }); }
[ "protected", "function", "registerCategoryProvider", "(", ")", "{", "$", "this", "->", "app", "[", "'categorize.category'", "]", "=", "$", "this", "->", "app", "->", "share", "(", "function", "(", "$", "app", ")", "{", "$", "model", "=", "$", "app", "[...
Register category provider. @return \CategoryProvider
[ "Register", "category", "provider", "." ]
bd183d7965cfcc709fef443e704e688faf2db715
https://github.com/teepluss/laravel4-categorize/blob/bd183d7965cfcc709fef443e704e688faf2db715/src/Teepluss/Categorize/CategorizeServiceProvider.php#L59-L67
train
teepluss/laravel4-categorize
src/Teepluss/Categorize/CategorizeServiceProvider.php
CategorizeServiceProvider.registerCategoryHierarchyProvider
protected function registerCategoryHierarchyProvider() { $this->app['categorize.categoryHierarchy'] = $this->app->share(function($app) { $model = $app['config']->get('categorize::categoryHierarchy.model'); return new CategoryHierarchyProvider($model); }); }
php
protected function registerCategoryHierarchyProvider() { $this->app['categorize.categoryHierarchy'] = $this->app->share(function($app) { $model = $app['config']->get('categorize::categoryHierarchy.model'); return new CategoryHierarchyProvider($model); }); }
[ "protected", "function", "registerCategoryHierarchyProvider", "(", ")", "{", "$", "this", "->", "app", "[", "'categorize.categoryHierarchy'", "]", "=", "$", "this", "->", "app", "->", "share", "(", "function", "(", "$", "app", ")", "{", "$", "model", "=", ...
Register category hierarchy provider. @return \CategoryHierarchyProvider
[ "Register", "category", "hierarchy", "provider", "." ]
bd183d7965cfcc709fef443e704e688faf2db715
https://github.com/teepluss/laravel4-categorize/blob/bd183d7965cfcc709fef443e704e688faf2db715/src/Teepluss/Categorize/CategorizeServiceProvider.php#L74-L82
train
teepluss/laravel4-categorize
src/Teepluss/Categorize/CategorizeServiceProvider.php
CategorizeServiceProvider.registerCategoryRelateProvider
protected function registerCategoryRelateProvider() { $this->app['categorize.categoryRelate'] = $this->app->share(function($app) { $model = $app['config']->get('categorize::categoryRelates.model'); return new CategoryRelateProvider($model); }); }
php
protected function registerCategoryRelateProvider() { $this->app['categorize.categoryRelate'] = $this->app->share(function($app) { $model = $app['config']->get('categorize::categoryRelates.model'); return new CategoryRelateProvider($model); }); }
[ "protected", "function", "registerCategoryRelateProvider", "(", ")", "{", "$", "this", "->", "app", "[", "'categorize.categoryRelate'", "]", "=", "$", "this", "->", "app", "->", "share", "(", "function", "(", "$", "app", ")", "{", "$", "model", "=", "$", ...
Register category relate provider. @return \CategoryHierarchyProvider
[ "Register", "category", "relate", "provider", "." ]
bd183d7965cfcc709fef443e704e688faf2db715
https://github.com/teepluss/laravel4-categorize/blob/bd183d7965cfcc709fef443e704e688faf2db715/src/Teepluss/Categorize/CategorizeServiceProvider.php#L89-L97
train
JantaoDev/SitemapBundle
Service/SitemapService.php
SitemapService.configureRobotsFile
protected function configureRobotsFile(RobotsFileInterface $robots) { $robots->setCrawlDelay($this->robots['crawl_delay']); foreach ($this->robots['allow'] as $path => $userAgent) { if (strpos($path, '/') === false) { $path = $this->router->generate($path); } $robots->addAllowEntry($path, $userAgent); } foreach ($this->robots['disallow'] as $path => $userAgent) { if (strpos($path, '/') === false) { $path = $this->router->generate($path); } $robots->addDisallowEntry($path, $userAgent); } foreach ($this->robots['clean_param'] as $path => $value) { $robots->addCleanParamEntry($value['parameters'], $path); } }
php
protected function configureRobotsFile(RobotsFileInterface $robots) { $robots->setCrawlDelay($this->robots['crawl_delay']); foreach ($this->robots['allow'] as $path => $userAgent) { if (strpos($path, '/') === false) { $path = $this->router->generate($path); } $robots->addAllowEntry($path, $userAgent); } foreach ($this->robots['disallow'] as $path => $userAgent) { if (strpos($path, '/') === false) { $path = $this->router->generate($path); } $robots->addDisallowEntry($path, $userAgent); } foreach ($this->robots['clean_param'] as $path => $value) { $robots->addCleanParamEntry($value['parameters'], $path); } }
[ "protected", "function", "configureRobotsFile", "(", "RobotsFileInterface", "$", "robots", ")", "{", "$", "robots", "->", "setCrawlDelay", "(", "$", "this", "->", "robots", "[", "'crawl_delay'", "]", ")", ";", "foreach", "(", "$", "this", "->", "robots", "["...
Modify robots file by configuration @param RobotsFileInterface $robots
[ "Modify", "robots", "file", "by", "configuration" ]
be21aafc2384d0430ee566bc8cec84de4a45ab03
https://github.com/JantaoDev/SitemapBundle/blob/be21aafc2384d0430ee566bc8cec84de4a45ab03/Service/SitemapService.php#L100-L118
train
digbang/security
src/Throttling/DoctrineThrottleRepository.php
DoctrineThrottleRepository.bulkSave
protected function bulkSave(array $throttles) { $entityManager = $this->getEntityManager(); foreach ($throttles as $throttle) { $entityManager->persist($throttle); } $entityManager->flush(); }
php
protected function bulkSave(array $throttles) { $entityManager = $this->getEntityManager(); foreach ($throttles as $throttle) { $entityManager->persist($throttle); } $entityManager->flush(); }
[ "protected", "function", "bulkSave", "(", "array", "$", "throttles", ")", "{", "$", "entityManager", "=", "$", "this", "->", "getEntityManager", "(", ")", ";", "foreach", "(", "$", "throttles", "as", "$", "throttle", ")", "{", "$", "entityManager", "->", ...
Persist an array of Throttles and flush them together. @param array $throttles
[ "Persist", "an", "array", "of", "Throttles", "and", "flush", "them", "together", "." ]
ee925c5a144a1553f5a72ded6f5a66c01a86ab21
https://github.com/digbang/security/blob/ee925c5a144a1553f5a72ded6f5a66c01a86ab21/src/Throttling/DoctrineThrottleRepository.php#L434-L444
train
19Gerhard85/sfSelect2WidgetsPlugin
lib/widgets/sfWidgetFormSelect2PropelChoiceSortable.class.php
sfWidgetFormSelect2PropelChoiceSortable.configure
protected function configure($options = array(), $attributes = array()) { $this->addOption('culture', sfContext::getInstance()->getUser()->getCulture()); $this->addOption('width', sfConfig::get('sf_sfSelect2Widgets_width')); $this->addRequiredOption('model'); $this->addOption('add_empty', false); $this->addOption('method', '__toString'); $this->addOption('key_method', 'getPrimaryKey'); $this->addOption('order_by', null); $this->addOption('query_methods', array()); $this->addOption('criteria', null); $this->addOption('connection', null); $this->addOption('multiple', false); // not used anymore $this->addOption('peer_method', 'doSelect'); parent::configure($options, $attributes); $this->setOption('type', 'hidden'); }
php
protected function configure($options = array(), $attributes = array()) { $this->addOption('culture', sfContext::getInstance()->getUser()->getCulture()); $this->addOption('width', sfConfig::get('sf_sfSelect2Widgets_width')); $this->addRequiredOption('model'); $this->addOption('add_empty', false); $this->addOption('method', '__toString'); $this->addOption('key_method', 'getPrimaryKey'); $this->addOption('order_by', null); $this->addOption('query_methods', array()); $this->addOption('criteria', null); $this->addOption('connection', null); $this->addOption('multiple', false); // not used anymore $this->addOption('peer_method', 'doSelect'); parent::configure($options, $attributes); $this->setOption('type', 'hidden'); }
[ "protected", "function", "configure", "(", "$", "options", "=", "array", "(", ")", ",", "$", "attributes", "=", "array", "(", ")", ")", "{", "$", "this", "->", "addOption", "(", "'culture'", ",", "sfContext", "::", "getInstance", "(", ")", "->", "getUs...
Configures the current widget. Available options: * url: The URL to call to get the choices to use (required) * config: A JavaScript array that configures the JQuery autocompleter widget * value_callback: A callback that converts the value before it is displayed @param array $options An array of options @param array $attributes An array of default HTML attributes @see sfWidgetForm
[ "Configures", "the", "current", "widget", "." ]
ce912eb0ddff2f288542b83d6847cbb17c736ac4
https://github.com/19Gerhard85/sfSelect2WidgetsPlugin/blob/ce912eb0ddff2f288542b83d6847cbb17c736ac4/lib/widgets/sfWidgetFormSelect2PropelChoiceSortable.class.php#L29-L47
train
digbang/security
src/Persistences/DoctrinePersistenceRepository.php
DoctrinePersistenceRepository.findUserByPersistenceCode
public function findUserByPersistenceCode($code) { $persistence = $this->findByPersistenceCode($code); if ($persistence) { return $persistence->getUser(); } return false; }
php
public function findUserByPersistenceCode($code) { $persistence = $this->findByPersistenceCode($code); if ($persistence) { return $persistence->getUser(); } return false; }
[ "public", "function", "findUserByPersistenceCode", "(", "$", "code", ")", "{", "$", "persistence", "=", "$", "this", "->", "findByPersistenceCode", "(", "$", "code", ")", ";", "if", "(", "$", "persistence", ")", "{", "return", "$", "persistence", "->", "ge...
Finds a user by persistence code. @param string $code @return \Digbang\Security\Users\DefaultUser|false
[ "Finds", "a", "user", "by", "persistence", "code", "." ]
ee925c5a144a1553f5a72ded6f5a66c01a86ab21
https://github.com/digbang/security/blob/ee925c5a144a1553f5a72ded6f5a66c01a86ab21/src/Persistences/DoctrinePersistenceRepository.php#L96-L106
train
digbang/security
src/Persistences/DoctrinePersistenceRepository.php
DoctrinePersistenceRepository.persist
public function persist(PersistableInterface $persistable, $remember = false) { try { if ($this->single) { $this->flush($persistable); } $code = $persistable->generatePersistenceCode(); $this->session->put($code); if ($remember === true) { $this->cookie->put($code); } $persistence = $this->create($persistable, $code); $entityManager = $this->getEntityManager(); $entityManager->persist($persistence); $entityManager->flush(); return true; } catch (\Exception $e) { return false; } }
php
public function persist(PersistableInterface $persistable, $remember = false) { try { if ($this->single) { $this->flush($persistable); } $code = $persistable->generatePersistenceCode(); $this->session->put($code); if ($remember === true) { $this->cookie->put($code); } $persistence = $this->create($persistable, $code); $entityManager = $this->getEntityManager(); $entityManager->persist($persistence); $entityManager->flush(); return true; } catch (\Exception $e) { return false; } }
[ "public", "function", "persist", "(", "PersistableInterface", "$", "persistable", ",", "$", "remember", "=", "false", ")", "{", "try", "{", "if", "(", "$", "this", "->", "single", ")", "{", "$", "this", "->", "flush", "(", "$", "persistable", ")", ";",...
Adds a new user persistence to the current session and attaches the user. @param User $persistable @param bool $remember @return bool
[ "Adds", "a", "new", "user", "persistence", "to", "the", "current", "session", "and", "attaches", "the", "user", "." ]
ee925c5a144a1553f5a72ded6f5a66c01a86ab21
https://github.com/digbang/security/blob/ee925c5a144a1553f5a72ded6f5a66c01a86ab21/src/Persistences/DoctrinePersistenceRepository.php#L115-L144
train
digbang/security
src/Persistences/DoctrinePersistenceRepository.php
DoctrinePersistenceRepository.remove
public function remove($code) { $entityManager = $this->getEntityManager(); $queryBuilder = $entityManager->createQueryBuilder(); $queryBuilder ->delete($this->entityName(), 'p') ->where('p.code = :code') ->setParameter('code', $code); return $queryBuilder->getQuery()->execute(); }
php
public function remove($code) { $entityManager = $this->getEntityManager(); $queryBuilder = $entityManager->createQueryBuilder(); $queryBuilder ->delete($this->entityName(), 'p') ->where('p.code = :code') ->setParameter('code', $code); return $queryBuilder->getQuery()->execute(); }
[ "public", "function", "remove", "(", "$", "code", ")", "{", "$", "entityManager", "=", "$", "this", "->", "getEntityManager", "(", ")", ";", "$", "queryBuilder", "=", "$", "entityManager", "->", "createQueryBuilder", "(", ")", ";", "$", "queryBuilder", "->...
Removes the given persistence code. @param string $code @return bool|null
[ "Removes", "the", "given", "persistence", "code", "." ]
ee925c5a144a1553f5a72ded6f5a66c01a86ab21
https://github.com/digbang/security/blob/ee925c5a144a1553f5a72ded6f5a66c01a86ab21/src/Persistences/DoctrinePersistenceRepository.php#L184-L195
train
digbang/security
src/Persistences/DoctrinePersistenceRepository.php
DoctrinePersistenceRepository.flush
public function flush(PersistableInterface $persistable, $forget = true) { if ($forget) { $this->forget(); } $code = $this->check(); $entityManager = $this->getEntityManager(); $queryBuilder = $entityManager->createQueryBuilder(); $queryBuilder ->delete($this->entityName(), 'p') ->where('p.user = :persistable') ->andWhere('p.code != :code'); $queryBuilder->setParameters([ 'persistable' => $persistable, 'code' => $code ]); $queryBuilder->getQuery()->execute(); }
php
public function flush(PersistableInterface $persistable, $forget = true) { if ($forget) { $this->forget(); } $code = $this->check(); $entityManager = $this->getEntityManager(); $queryBuilder = $entityManager->createQueryBuilder(); $queryBuilder ->delete($this->entityName(), 'p') ->where('p.user = :persistable') ->andWhere('p.code != :code'); $queryBuilder->setParameters([ 'persistable' => $persistable, 'code' => $code ]); $queryBuilder->getQuery()->execute(); }
[ "public", "function", "flush", "(", "PersistableInterface", "$", "persistable", ",", "$", "forget", "=", "true", ")", "{", "if", "(", "$", "forget", ")", "{", "$", "this", "->", "forget", "(", ")", ";", "}", "$", "code", "=", "$", "this", "->", "ch...
Flushes persistences for the given user. @param PersistableInterface $persistable @param bool $forget @return void
[ "Flushes", "persistences", "for", "the", "given", "user", "." ]
ee925c5a144a1553f5a72ded6f5a66c01a86ab21
https://github.com/digbang/security/blob/ee925c5a144a1553f5a72ded6f5a66c01a86ab21/src/Persistences/DoctrinePersistenceRepository.php#L205-L228
train
mvccore/packager
src/Packager/Phar.php
Packager_Phar.Run
public function Run () { parent::PreRun(); list($jobMethod, $params) = $this->completeJobAndParams(); $this->$jobMethod($params); return $this; }
php
public function Run () { parent::PreRun(); list($jobMethod, $params) = $this->completeJobAndParams(); $this->$jobMethod($params); return $this; }
[ "public", "function", "Run", "(", ")", "{", "parent", "::", "PreRun", "(", ")", ";", "list", "(", "$", "jobMethod", ",", "$", "params", ")", "=", "$", "this", "->", "completeJobAndParams", "(", ")", ";", "$", "this", "->", "$", "jobMethod", "(", "$...
Run PHAR compilation process, print output to CLI or browser @return Packager_Phar
[ "Run", "PHAR", "compilation", "process", "print", "output", "to", "CLI", "or", "browser" ]
614f21267bbe53e0e9286fc5ca3eb5d1df14b577
https://github.com/mvccore/packager/blob/614f21267bbe53e0e9286fc5ca3eb5d1df14b577/src/Packager/Phar.php#L176-L181
train
MichaelPavlista/palette
src/Generator/CurrentExecution.php
CurrentExecution.loadPicture
public function loadPicture($image, $worker = NULL) { if($this->pictureLoader) { return $this->pictureLoader->loadPicture($image, $this, $worker); } return new Picture($image, $this, $worker, $this->fallbackImage); }
php
public function loadPicture($image, $worker = NULL) { if($this->pictureLoader) { return $this->pictureLoader->loadPicture($image, $this, $worker); } return new Picture($image, $this, $worker, $this->fallbackImage); }
[ "public", "function", "loadPicture", "(", "$", "image", ",", "$", "worker", "=", "NULL", ")", "{", "if", "(", "$", "this", "->", "pictureLoader", ")", "{", "return", "$", "this", "->", "pictureLoader", "->", "loadPicture", "(", "$", "image", ",", "$", ...
Get picture instance for transformation performs by this picture generator. @param string $image path to image file @param string|null $worker Palette\Picture worker constant @return Picture
[ "Get", "picture", "instance", "for", "transformation", "performs", "by", "this", "picture", "generator", "." ]
dfb8d0e1b98880932851233faa048e2bfc9abed5
https://github.com/MichaelPavlista/palette/blob/dfb8d0e1b98880932851233faa048e2bfc9abed5/src/Generator/CurrentExecution.php#L77-L85
train
MichaelPavlista/palette
src/Generator/CurrentExecution.php
CurrentExecution.save
public function save(Picture $picture) { $pictureFile = $this->getPath($picture); if(!$this->isFileActual($pictureFile, $picture)) { $picture->save($pictureFile); } }
php
public function save(Picture $picture) { $pictureFile = $this->getPath($picture); if(!$this->isFileActual($pictureFile, $picture)) { $picture->save($pictureFile); } }
[ "public", "function", "save", "(", "Picture", "$", "picture", ")", "{", "$", "pictureFile", "=", "$", "this", "->", "getPath", "(", "$", "picture", ")", ";", "if", "(", "!", "$", "this", "->", "isFileActual", "(", "$", "pictureFile", ",", "$", "pictu...
Save picture variant to generator storage. @param Picture $picture @return void
[ "Save", "picture", "variant", "to", "generator", "storage", "." ]
dfb8d0e1b98880932851233faa048e2bfc9abed5
https://github.com/MichaelPavlista/palette/blob/dfb8d0e1b98880932851233faa048e2bfc9abed5/src/Generator/CurrentExecution.php#L104-L112
train
MichaelPavlista/palette
src/Generator/CurrentExecution.php
CurrentExecution.isFileActual
protected function isFileActual($file, Picture $picture) { if(file_exists($file)) { if(@filemtime($file) === @filemtime($picture->getImage())) { return TRUE; } else { return NULL; } } return FALSE; }
php
protected function isFileActual($file, Picture $picture) { if(file_exists($file)) { if(@filemtime($file) === @filemtime($picture->getImage())) { return TRUE; } else { return NULL; } } return FALSE; }
[ "protected", "function", "isFileActual", "(", "$", "file", ",", "Picture", "$", "picture", ")", "{", "if", "(", "file_exists", "(", "$", "file", ")", ")", "{", "if", "(", "@", "filemtime", "(", "$", "file", ")", "===", "@", "filemtime", "(", "$", "...
Check if picture variant exists and is actual @param string $file @param Picture $picture @return bool|null
[ "Check", "if", "picture", "variant", "exists", "and", "is", "actual" ]
dfb8d0e1b98880932851233faa048e2bfc9abed5
https://github.com/MichaelPavlista/palette/blob/dfb8d0e1b98880932851233faa048e2bfc9abed5/src/Generator/CurrentExecution.php#L156-L171
train
MichaelPavlista/palette
src/Generator/CurrentExecution.php
CurrentExecution.setFallbackImage
public function setFallbackImage($fallbackImage) { $fallbackImagePath = realpath($fallbackImage); if(file_exists($fallbackImagePath) && is_readable($fallbackImagePath)) { $this->fallbackImage = $fallbackImagePath; return; } throw new Exception("Default image missing or not readable, path: $fallbackImage"); }
php
public function setFallbackImage($fallbackImage) { $fallbackImagePath = realpath($fallbackImage); if(file_exists($fallbackImagePath) && is_readable($fallbackImagePath)) { $this->fallbackImage = $fallbackImagePath; return; } throw new Exception("Default image missing or not readable, path: $fallbackImage"); }
[ "public", "function", "setFallbackImage", "(", "$", "fallbackImage", ")", "{", "$", "fallbackImagePath", "=", "realpath", "(", "$", "fallbackImage", ")", ";", "if", "(", "file_exists", "(", "$", "fallbackImagePath", ")", "&&", "is_readable", "(", "$", "fallbac...
Set fallback image witch is used when requred image is not found. @param string $fallbackImage absolute or relative path to fallback image. @throws Exception
[ "Set", "fallback", "image", "witch", "is", "used", "when", "requred", "image", "is", "not", "found", "." ]
dfb8d0e1b98880932851233faa048e2bfc9abed5
https://github.com/MichaelPavlista/palette/blob/dfb8d0e1b98880932851233faa048e2bfc9abed5/src/Generator/CurrentExecution.php#L200-L212
train
MichaelPavlista/palette
src/Generator/CurrentExecution.php
CurrentExecution.getTemplateQuery
public function getTemplateQuery($template) { if(isset($this->template[$template])) { return $this->template[$template]; } return FALSE; }
php
public function getTemplateQuery($template) { if(isset($this->template[$template])) { return $this->template[$template]; } return FALSE; }
[ "public", "function", "getTemplateQuery", "(", "$", "template", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "template", "[", "$", "template", "]", ")", ")", "{", "return", "$", "this", "->", "template", "[", "$", "template", "]", ";", "}", ...
Get defined template image query @param string $template @return string|bool
[ "Get", "defined", "template", "image", "query" ]
dfb8d0e1b98880932851233faa048e2bfc9abed5
https://github.com/MichaelPavlista/palette/blob/dfb8d0e1b98880932851233faa048e2bfc9abed5/src/Generator/CurrentExecution.php#L242-L250
train
MichaelPavlista/palette
src/Generator/CurrentExecution.php
CurrentExecution.unifyPath
protected function unifyPath($path, $slash = DIRECTORY_SEPARATOR) { return preg_replace('/\\'. $slash .'+/', $slash, str_replace(array('/', "\\"), $slash, $path)); }
php
protected function unifyPath($path, $slash = DIRECTORY_SEPARATOR) { return preg_replace('/\\'. $slash .'+/', $slash, str_replace(array('/', "\\"), $slash, $path)); }
[ "protected", "function", "unifyPath", "(", "$", "path", ",", "$", "slash", "=", "DIRECTORY_SEPARATOR", ")", "{", "return", "preg_replace", "(", "'/\\\\'", ".", "$", "slash", ".", "'+/'", ",", "$", "slash", ",", "str_replace", "(", "array", "(", "'/'", ",...
Unify filesystem path @param string $path @param string $slash @return string
[ "Unify", "filesystem", "path" ]
dfb8d0e1b98880932851233faa048e2bfc9abed5
https://github.com/MichaelPavlista/palette/blob/dfb8d0e1b98880932851233faa048e2bfc9abed5/src/Generator/CurrentExecution.php#L258-L261
train
dazzle-php/promise
src/Promise/Promise.php
Promise.settle
protected function settle(PromiseInterface $promise) { $handlers = $this->handlers; $this->result = $promise; $this->handlers = []; foreach ($handlers as $handler) { $handler($promise); } return $promise; }
php
protected function settle(PromiseInterface $promise) { $handlers = $this->handlers; $this->result = $promise; $this->handlers = []; foreach ($handlers as $handler) { $handler($promise); } return $promise; }
[ "protected", "function", "settle", "(", "PromiseInterface", "$", "promise", ")", "{", "$", "handlers", "=", "$", "this", "->", "handlers", ";", "$", "this", "->", "result", "=", "$", "promise", ";", "$", "this", "->", "handlers", "=", "[", "]", ";", ...
Settle Promise with another Promise. @see PromiseInterface::resolve @see PromiseInterface::reject @see PromiseInterface::cancel @param PromiseInterface $promise @return PromiseInterface @resolves mixed|null @rejects Error|Exception|string|null @cancels Error|Exception|string|null
[ "Settle", "Promise", "with", "another", "Promise", "." ]
0df259f657bb21f8187823cf1a2499cf5b8bc461
https://github.com/dazzle-php/promise/blob/0df259f657bb21f8187823cf1a2499cf5b8bc461/src/Promise/Promise.php#L336-L349
train
dazzle-php/promise
src/Promise/Promise.php
Promise.getResult
protected function getResult() { while ($this->result instanceof Promise && null !== $this->result->result) { $this->result = $this->result->result; } return $this->result; }
php
protected function getResult() { while ($this->result instanceof Promise && null !== $this->result->result) { $this->result = $this->result->result; } return $this->result; }
[ "protected", "function", "getResult", "(", ")", "{", "while", "(", "$", "this", "->", "result", "instanceof", "Promise", "&&", "null", "!==", "$", "this", "->", "result", "->", "result", ")", "{", "$", "this", "->", "result", "=", "$", "this", "->", ...
Get Promise result. Returns fulfilled, rejected or cancelled Promise for settled Promises or null for pending. @return PromiseInterface|null
[ "Get", "Promise", "result", ".", "Returns", "fulfilled", "rejected", "or", "cancelled", "Promise", "for", "settled", "Promises", "or", "null", "for", "pending", "." ]
0df259f657bb21f8187823cf1a2499cf5b8bc461
https://github.com/dazzle-php/promise/blob/0df259f657bb21f8187823cf1a2499cf5b8bc461/src/Promise/Promise.php#L356-L364
train
dazzle-php/promise
src/Promise/Promise.php
Promise.mutate
protected function mutate(callable $resolver = null) { if ($resolver === null) { return; } try { $resolver( function ($value = null) { $this->resolve($value); }, function ($reason = null) { $this->reject($reason); }, function ($reason = null) { $this->cancel($reason); } ); } catch (Error $ex) { $this->reject($ex); } catch (Exception $ex) { $this->reject($ex); } }
php
protected function mutate(callable $resolver = null) { if ($resolver === null) { return; } try { $resolver( function ($value = null) { $this->resolve($value); }, function ($reason = null) { $this->reject($reason); }, function ($reason = null) { $this->cancel($reason); } ); } catch (Error $ex) { $this->reject($ex); } catch (Exception $ex) { $this->reject($ex); } }
[ "protected", "function", "mutate", "(", "callable", "$", "resolver", "=", "null", ")", "{", "if", "(", "$", "resolver", "===", "null", ")", "{", "return", ";", "}", "try", "{", "$", "resolver", "(", "function", "(", "$", "value", "=", "null", ")", ...
Mutate resolver. @param callable|null $resolver
[ "Mutate", "resolver", "." ]
0df259f657bb21f8187823cf1a2499cf5b8bc461
https://github.com/dazzle-php/promise/blob/0df259f657bb21f8187823cf1a2499cf5b8bc461/src/Promise/Promise.php#L371-L400
train
christianblos/codedocs
src/Doc/Lexer.php
Lexer.getNext
public function getNext() { if ($this->currentToken !== null || strlen($this->currentInput) > 0) { $this->parseNextToken(); return $this->currentToken; } return null; }
php
public function getNext() { if ($this->currentToken !== null || strlen($this->currentInput) > 0) { $this->parseNextToken(); return $this->currentToken; } return null; }
[ "public", "function", "getNext", "(", ")", "{", "if", "(", "$", "this", "->", "currentToken", "!==", "null", "||", "strlen", "(", "$", "this", "->", "currentInput", ")", ">", "0", ")", "{", "$", "this", "->", "parseNextToken", "(", ")", ";", "return"...
Get next token @return array @throws Exception
[ "Get", "next", "token" ]
f78e0803ad96605b463f2e40b8e9bfe06c5a3aab
https://github.com/christianblos/codedocs/blob/f78e0803ad96605b463f2e40b8e9bfe06c5a3aab/src/Doc/Lexer.php#L102-L111
train
christianblos/codedocs
src/Doc/Lexer.php
Lexer.scanNextType
private function scanNextType($string) { foreach ($this->patterns as $type => $pattern) { if (preg_match('/^(' . $pattern . ')/sS', $string, $matches) === 1) { return [ 'type' => $type, 'match' => $matches[1], 'length' => strlen($matches[1]), ]; } } return null; }
php
private function scanNextType($string) { foreach ($this->patterns as $type => $pattern) { if (preg_match('/^(' . $pattern . ')/sS', $string, $matches) === 1) { return [ 'type' => $type, 'match' => $matches[1], 'length' => strlen($matches[1]), ]; } } return null; }
[ "private", "function", "scanNextType", "(", "$", "string", ")", "{", "foreach", "(", "$", "this", "->", "patterns", "as", "$", "type", "=>", "$", "pattern", ")", "{", "if", "(", "preg_match", "(", "'/^('", ".", "$", "pattern", ".", "')/sS'", ",", "$"...
Determines the next type of the given string @param string $string @return array|null
[ "Determines", "the", "next", "type", "of", "the", "given", "string" ]
f78e0803ad96605b463f2e40b8e9bfe06c5a3aab
https://github.com/christianblos/codedocs/blob/f78e0803ad96605b463f2e40b8e9bfe06c5a3aab/src/Doc/Lexer.php#L150-L163
train
christianblos/codedocs
src/Doc/Lexer.php
Lexer.getAnyType
private function getAnyType($string) { $anyString = ''; do { $anyString .= $string[0]; $string = substr($string, 1); $typeInfo = $this->scanNextType($string); // ignore all until markup reached if ($typeInfo['type'] !== self::T_MARKUP_OPEN && $typeInfo['type'] !== self::T_MARKUP_OPEN_ESCAPED) { $typeInfo = null; } } while ($typeInfo === null && $string); return [ 'type' => self::T_ANY, 'match' => $anyString, 'length' => strlen($anyString), ]; }
php
private function getAnyType($string) { $anyString = ''; do { $anyString .= $string[0]; $string = substr($string, 1); $typeInfo = $this->scanNextType($string); // ignore all until markup reached if ($typeInfo['type'] !== self::T_MARKUP_OPEN && $typeInfo['type'] !== self::T_MARKUP_OPEN_ESCAPED) { $typeInfo = null; } } while ($typeInfo === null && $string); return [ 'type' => self::T_ANY, 'match' => $anyString, 'length' => strlen($anyString), ]; }
[ "private", "function", "getAnyType", "(", "$", "string", ")", "{", "$", "anyString", "=", "''", ";", "do", "{", "$", "anyString", ".=", "$", "string", "[", "0", "]", ";", "$", "string", "=", "substr", "(", "$", "string", ",", "1", ")", ";", "$", ...
Get next ANY-type which is a string that does not match to any token @param string $string @return array|null
[ "Get", "next", "ANY", "-", "type", "which", "is", "a", "string", "that", "does", "not", "match", "to", "any", "token" ]
f78e0803ad96605b463f2e40b8e9bfe06c5a3aab
https://github.com/christianblos/codedocs/blob/f78e0803ad96605b463f2e40b8e9bfe06c5a3aab/src/Doc/Lexer.php#L172-L193
train
scherersoftware/cake-cktools
src/Controller/Component/MaintenanceComponent.php
MaintenanceComponent.beforeFilter
public function beforeFilter() { if (defined('PHPUNIT_TESTSUITE')) { return; } $maintenancePage = Environment::read('MAINTENANCE_PAGE_REDIRECT_URL'); $currentUrl = $this->_controller->getRequest()->here; $accessibleUrls = explode('|', Environment::read('MAINTENANCE_ACCESSIBLE_URLS')); $accessibleUrls[] = $maintenancePage; if (!self::isMaintenanceActive()) { // if maintenance is not active but maintenance page is requested -> redirect to default page if (in_array($currentUrl, $accessibleUrls) && substr($maintenancePage, -strlen($currentUrl)) === $currentUrl) { $maintenanceBasePage = Environment::read('MAINTENANCE_BASE_URL'); return $this->_controller->redirect($maintenanceBasePage); } return; } $cookieName = Environment::read('MAINTENANCE_COOKIE_NAME'); $cookieExists = ($this->_controller->Cookie->read($cookieName) !== null); if ($cookieExists) { return; } $headerActive = Environment::read('MAINTENANCE_HEADER_ACTIVE'); $headerName = Environment::read('MAINTENANCE_HEADER_NAME'); $headerValue = Environment::read('MAINTENANCE_HEADER_VALUE'); $successUrl = Environment::read('MAINTENANCE_PASSWORD_SUCCESS_URL'); if ($headerActive && !empty($this->_controller->request->getHeader($headerName)) && $this->_controller->request->getHeader($headerName) === $headerValue ) { $this->_controller->Cookie->write($cookieName, true); return $this->_controller->redirect($successUrl); } $passwordUrl = Environment::read('MAINTENANCE_PASSWORD_URL'); $accessibleUrls[] = $passwordUrl; if (!in_array($currentUrl, $accessibleUrls)) { return $this->_controller->redirect($maintenancePage); } if ($currentUrl != $passwordUrl) { return; } $user = Environment::read('MAINTENANCE_USER'); $password = Environment::read('MAINTENANCE_PASSWORD'); if ($currentUrl == $passwordUrl) { if (!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="Maintenance Realm"'); header('HTTP/1.0 401 Unauthorized'); echo 'Unauthorized'; exit; } if ($_SERVER['PHP_AUTH_USER'] === $user && $_SERVER['PHP_AUTH_PW'] === $password) { $this->_controller->Cookie->write($cookieName, true); return $this->_controller->redirect($successUrl); } return $this->_controller->redirect($maintenancePage); } return $this->_controller->redirect($maintenancePage); }
php
public function beforeFilter() { if (defined('PHPUNIT_TESTSUITE')) { return; } $maintenancePage = Environment::read('MAINTENANCE_PAGE_REDIRECT_URL'); $currentUrl = $this->_controller->getRequest()->here; $accessibleUrls = explode('|', Environment::read('MAINTENANCE_ACCESSIBLE_URLS')); $accessibleUrls[] = $maintenancePage; if (!self::isMaintenanceActive()) { // if maintenance is not active but maintenance page is requested -> redirect to default page if (in_array($currentUrl, $accessibleUrls) && substr($maintenancePage, -strlen($currentUrl)) === $currentUrl) { $maintenanceBasePage = Environment::read('MAINTENANCE_BASE_URL'); return $this->_controller->redirect($maintenanceBasePage); } return; } $cookieName = Environment::read('MAINTENANCE_COOKIE_NAME'); $cookieExists = ($this->_controller->Cookie->read($cookieName) !== null); if ($cookieExists) { return; } $headerActive = Environment::read('MAINTENANCE_HEADER_ACTIVE'); $headerName = Environment::read('MAINTENANCE_HEADER_NAME'); $headerValue = Environment::read('MAINTENANCE_HEADER_VALUE'); $successUrl = Environment::read('MAINTENANCE_PASSWORD_SUCCESS_URL'); if ($headerActive && !empty($this->_controller->request->getHeader($headerName)) && $this->_controller->request->getHeader($headerName) === $headerValue ) { $this->_controller->Cookie->write($cookieName, true); return $this->_controller->redirect($successUrl); } $passwordUrl = Environment::read('MAINTENANCE_PASSWORD_URL'); $accessibleUrls[] = $passwordUrl; if (!in_array($currentUrl, $accessibleUrls)) { return $this->_controller->redirect($maintenancePage); } if ($currentUrl != $passwordUrl) { return; } $user = Environment::read('MAINTENANCE_USER'); $password = Environment::read('MAINTENANCE_PASSWORD'); if ($currentUrl == $passwordUrl) { if (!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="Maintenance Realm"'); header('HTTP/1.0 401 Unauthorized'); echo 'Unauthorized'; exit; } if ($_SERVER['PHP_AUTH_USER'] === $user && $_SERVER['PHP_AUTH_PW'] === $password) { $this->_controller->Cookie->write($cookieName, true); return $this->_controller->redirect($successUrl); } return $this->_controller->redirect($maintenancePage); } return $this->_controller->redirect($maintenancePage); }
[ "public", "function", "beforeFilter", "(", ")", "{", "if", "(", "defined", "(", "'PHPUNIT_TESTSUITE'", ")", ")", "{", "return", ";", "}", "$", "maintenancePage", "=", "Environment", "::", "read", "(", "'MAINTENANCE_PAGE_REDIRECT_URL'", ")", ";", "$", "currentU...
Maintenance redirect logic @return mixed
[ "Maintenance", "redirect", "logic" ]
efba42cf4e1804df8f1faa83ef75927bee6c206b
https://github.com/scherersoftware/cake-cktools/blob/efba42cf4e1804df8f1faa83ef75927bee6c206b/src/Controller/Component/MaintenanceComponent.php#L49-L116
train
mylukin/pscws4
src/XDB_R.php
XDB_R.Get
function Get($key) { // check the file description if (!$this->fd) { trigger_error("XDB:Get(), null db handler.", E_USER_WARNING); return false; } $klen = strlen($key); if ($klen == 0 || $klen > XDB_MAXKLEN) return false; // get the data? $rec = $this->_get_record($key); if (!isset($rec['vlen']) || $rec['vlen'] == 0) return false; return $rec['value']; }
php
function Get($key) { // check the file description if (!$this->fd) { trigger_error("XDB:Get(), null db handler.", E_USER_WARNING); return false; } $klen = strlen($key); if ($klen == 0 || $klen > XDB_MAXKLEN) return false; // get the data? $rec = $this->_get_record($key); if (!isset($rec['vlen']) || $rec['vlen'] == 0) return false; return $rec['value']; }
[ "function", "Get", "(", "$", "key", ")", "{", "// check the file description", "if", "(", "!", "$", "this", "->", "fd", ")", "{", "trigger_error", "(", "\"XDB:Get(), null db handler.\"", ",", "E_USER_WARNING", ")", ";", "return", "false", ";", "}", "$", "kle...
Read the value by key
[ "Read", "the", "value", "by", "key" ]
b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b
https://github.com/mylukin/pscws4/blob/b5b2bd28998a5f33db7c9acc054bdc4c47a02f1b/src/XDB_R.php#L74-L92
train
teepluss/laravel4-categorize
src/Teepluss/Categorize/Categories/Provider.php
Provider.root
public function root() { $category = $this->createModel(); $category = $category->whereExists(function($query) { $query->select(\DB::raw(1)) ->from('category_hierarchy') ->whereRaw(DB::getTablePrefix().'categories.id = '.DB::getTablePrefix().'category_hierarchy.category_id') ->where('category_hierarchy.category_parent_id', 0); }); return $category; }
php
public function root() { $category = $this->createModel(); $category = $category->whereExists(function($query) { $query->select(\DB::raw(1)) ->from('category_hierarchy') ->whereRaw(DB::getTablePrefix().'categories.id = '.DB::getTablePrefix().'category_hierarchy.category_id') ->where('category_hierarchy.category_parent_id', 0); }); return $category; }
[ "public", "function", "root", "(", ")", "{", "$", "category", "=", "$", "this", "->", "createModel", "(", ")", ";", "$", "category", "=", "$", "category", "->", "whereExists", "(", "function", "(", "$", "query", ")", "{", "$", "query", "->", "select"...
Get only root category. @return Category
[ "Get", "only", "root", "category", "." ]
bd183d7965cfcc709fef443e704e688faf2db715
https://github.com/teepluss/laravel4-categorize/blob/bd183d7965cfcc709fef443e704e688faf2db715/src/Teepluss/Categorize/Categories/Provider.php#L33-L46
train
ezsystems/ezmultiupload
classes/ezmultiuploadhandler.php
eZMultiuploadHandler.exec
static function exec( $method, &$result ) { $ini = eZINI::instance( 'ezmultiupload.ini' ); $handlers = $ini->variable( 'MultiUploadSettings', 'MultiuploadHandlers' ); if ( !$handlers ) return false; foreach ( $handlers as $hanlder ) { if ( !call_user_func( array( $hanlder, $method ), $result ) ) eZDebug::writeWarning( 'Multiupload handler implementation not found' ); } return true; }
php
static function exec( $method, &$result ) { $ini = eZINI::instance( 'ezmultiupload.ini' ); $handlers = $ini->variable( 'MultiUploadSettings', 'MultiuploadHandlers' ); if ( !$handlers ) return false; foreach ( $handlers as $hanlder ) { if ( !call_user_func( array( $hanlder, $method ), $result ) ) eZDebug::writeWarning( 'Multiupload handler implementation not found' ); } return true; }
[ "static", "function", "exec", "(", "$", "method", ",", "&", "$", "result", ")", "{", "$", "ini", "=", "eZINI", "::", "instance", "(", "'ezmultiupload.ini'", ")", ";", "$", "handlers", "=", "$", "ini", "->", "variable", "(", "'MultiUploadSettings'", ",", ...
Call preUpload or postUpload user definied functions. @static @param string $method @param array $result @return bool
[ "Call", "preUpload", "or", "postUpload", "user", "definied", "functions", "." ]
80cfe475de4d6755ed7bcdec8aaf7cf3e1bb399e
https://github.com/ezsystems/ezmultiupload/blob/80cfe475de4d6755ed7bcdec8aaf7cf3e1bb399e/classes/ezmultiuploadhandler.php#L25-L40
train
silvercommerce/shoppingcart
src/ShoppingCartFactory.php
ShoppingCartFactory.findOrMakeCart
public function findOrMakeCart() { $cookies = $this->cookiesSupported(); $session = $this->getSession(); $classname = self::config()->model; $cart = null; $write = false; $member = Security::getCurrentUser(); if ($cookies) { $cart_id = Cookie::get(self::COOKIE_NAME); } else { $cart_id = $session->get(self::COOKIE_NAME); } // Try to get a cart from the the DB if (isset($cart_id)) { $cart = $classname::get()->find('AccessKey', $cart_id); } // Does the current member have a cart? if (empty($cart) && isset($member) && $member->getCart()) { $cart = $member->getCart(); } // Finally, if nothing is set, create a new instance to return if (empty($cart)) { $cart = $classname::create(); } return $cart; }
php
public function findOrMakeCart() { $cookies = $this->cookiesSupported(); $session = $this->getSession(); $classname = self::config()->model; $cart = null; $write = false; $member = Security::getCurrentUser(); if ($cookies) { $cart_id = Cookie::get(self::COOKIE_NAME); } else { $cart_id = $session->get(self::COOKIE_NAME); } // Try to get a cart from the the DB if (isset($cart_id)) { $cart = $classname::get()->find('AccessKey', $cart_id); } // Does the current member have a cart? if (empty($cart) && isset($member) && $member->getCart()) { $cart = $member->getCart(); } // Finally, if nothing is set, create a new instance to return if (empty($cart)) { $cart = $classname::create(); } return $cart; }
[ "public", "function", "findOrMakeCart", "(", ")", "{", "$", "cookies", "=", "$", "this", "->", "cookiesSupported", "(", ")", ";", "$", "session", "=", "$", "this", "->", "getSession", "(", ")", ";", "$", "classname", "=", "self", "::", "config", "(", ...
Either find an existing cart, or create a new one. @return ShoppingCartModel
[ "Either", "find", "an", "existing", "cart", "or", "create", "a", "new", "one", "." ]
11e1296c095f9c2d35395d8d3b9d30e8a9db745b
https://github.com/silvercommerce/shoppingcart/blob/11e1296c095f9c2d35395d8d3b9d30e8a9db745b/src/ShoppingCartFactory.php#L132-L163
train
silvercommerce/shoppingcart
src/ShoppingCartFactory.php
ShoppingCartFactory.cleanOld
public function cleanOld() { $siteconfig = SiteConfig::current_site_config(); $date = $siteconfig->dbobject("LastEstimateClean"); $request = Injector::inst()->get(HTTPRequest::class); if (!$date || ($date && !$date->IsToday())) { $task = Injector::inst()->create(CleanExpiredEstimatesTask::class); $task->setSilent(true); $task->run($request); $siteconfig->LastEstimateClean = DBDatetime::now()->Value; $siteconfig->write(); } }
php
public function cleanOld() { $siteconfig = SiteConfig::current_site_config(); $date = $siteconfig->dbobject("LastEstimateClean"); $request = Injector::inst()->get(HTTPRequest::class); if (!$date || ($date && !$date->IsToday())) { $task = Injector::inst()->create(CleanExpiredEstimatesTask::class); $task->setSilent(true); $task->run($request); $siteconfig->LastEstimateClean = DBDatetime::now()->Value; $siteconfig->write(); } }
[ "public", "function", "cleanOld", "(", ")", "{", "$", "siteconfig", "=", "SiteConfig", "::", "current_site_config", "(", ")", ";", "$", "date", "=", "$", "siteconfig", "->", "dbobject", "(", "\"LastEstimateClean\"", ")", ";", "$", "request", "=", "Injector",...
Run the task to clean old shopping carts @return null
[ "Run", "the", "task", "to", "clean", "old", "shopping", "carts" ]
11e1296c095f9c2d35395d8d3b9d30e8a9db745b
https://github.com/silvercommerce/shoppingcart/blob/11e1296c095f9c2d35395d8d3b9d30e8a9db745b/src/ShoppingCartFactory.php#L170-L183
train
silvercommerce/shoppingcart
src/ShoppingCartFactory.php
ShoppingCartFactory.cookiesSupported
public function cookiesSupported() { Cookie::set(self::TEST_COOKIE, 1); $cookie = Cookie::get(self::TEST_COOKIE); Cookie::force_expiry(self::TEST_COOKIE); return (empty($cookie)) ? false : true; }
php
public function cookiesSupported() { Cookie::set(self::TEST_COOKIE, 1); $cookie = Cookie::get(self::TEST_COOKIE); Cookie::force_expiry(self::TEST_COOKIE); return (empty($cookie)) ? false : true; }
[ "public", "function", "cookiesSupported", "(", ")", "{", "Cookie", "::", "set", "(", "self", "::", "TEST_COOKIE", ",", "1", ")", ";", "$", "cookie", "=", "Cookie", "::", "get", "(", "self", "::", "TEST_COOKIE", ")", ";", "Cookie", "::", "force_expiry", ...
Test to see if the current user supports cookies @return boolean
[ "Test", "to", "see", "if", "the", "current", "user", "supports", "cookies" ]
11e1296c095f9c2d35395d8d3b9d30e8a9db745b
https://github.com/silvercommerce/shoppingcart/blob/11e1296c095f9c2d35395d8d3b9d30e8a9db745b/src/ShoppingCartFactory.php#L190-L197
train
silvercommerce/shoppingcart
src/ShoppingCartFactory.php
ShoppingCartFactory.addItem
public function addItem($item, $customisations = []) { $cart = $this->getCurrent(); $stock_item = $item->FindStockItem(); $added = false; if (!$item instanceof LineItem) { throw new ValidationException(_t( "ShoppingCart.WrongItemClass", "Item needs to be of class {class}", ["class" => LineItem::class] )); } // Start off by writing our item object (if it is // not in the DB) if (!$item->exists()) { $item->write(); } if (!is_array($customisations)) { $customisations = [$customisations]; } // Find any item customisation associations $custom_association = null; $custom_associations = array_merge( $item->hasMany(), $item->manyMany() ); // Define association of item to customisations foreach ($custom_associations as $key => $value) { $class = $value::create(); if ($class instanceof LineItemCustomisation) { $custom_association = $key; break; } } // Map any customisations to the current item if (isset($custom_association)) { $item->write(); foreach ($customisations as $customisation) { if ($customisation instanceof LineItemCustomisation) { if (!$customisation->exists()) { $customisation->write(); } $item->{$custom_association}()->add($customisation); } } } // Ensure we update the item key $item->write(); // If the current cart isn't in the DB, save it if (!$cart->exists()) { $this->save(); } // Check if object already in the cart, update quantity // and delete new item $existing_item = $cart->Items()->find("Key", $item->Key); if (isset($existing_item)) { $this->updateItem( $existing_item, $existing_item->Quantity + $item->Quantity ); $item->delete(); $added = true; } // If no update was sucessfull then add item if (!$added) { // If we need to track stock, do it now if ($stock_item && ($stock_item->Stocked || $this->config()->check_stock_levels)) { if ($item->checkStockLevel($item->Quantity) < 0) { throw new ValidationException(_t( "ShoppingCart.NotEnoughStock", "There are not enough '{title}' in stock", ['title' => $stock_item->Title] )); } } $item->ParentID = $cart->ID; $item->write(); } $this->save(); return $this; }
php
public function addItem($item, $customisations = []) { $cart = $this->getCurrent(); $stock_item = $item->FindStockItem(); $added = false; if (!$item instanceof LineItem) { throw new ValidationException(_t( "ShoppingCart.WrongItemClass", "Item needs to be of class {class}", ["class" => LineItem::class] )); } // Start off by writing our item object (if it is // not in the DB) if (!$item->exists()) { $item->write(); } if (!is_array($customisations)) { $customisations = [$customisations]; } // Find any item customisation associations $custom_association = null; $custom_associations = array_merge( $item->hasMany(), $item->manyMany() ); // Define association of item to customisations foreach ($custom_associations as $key => $value) { $class = $value::create(); if ($class instanceof LineItemCustomisation) { $custom_association = $key; break; } } // Map any customisations to the current item if (isset($custom_association)) { $item->write(); foreach ($customisations as $customisation) { if ($customisation instanceof LineItemCustomisation) { if (!$customisation->exists()) { $customisation->write(); } $item->{$custom_association}()->add($customisation); } } } // Ensure we update the item key $item->write(); // If the current cart isn't in the DB, save it if (!$cart->exists()) { $this->save(); } // Check if object already in the cart, update quantity // and delete new item $existing_item = $cart->Items()->find("Key", $item->Key); if (isset($existing_item)) { $this->updateItem( $existing_item, $existing_item->Quantity + $item->Quantity ); $item->delete(); $added = true; } // If no update was sucessfull then add item if (!$added) { // If we need to track stock, do it now if ($stock_item && ($stock_item->Stocked || $this->config()->check_stock_levels)) { if ($item->checkStockLevel($item->Quantity) < 0) { throw new ValidationException(_t( "ShoppingCart.NotEnoughStock", "There are not enough '{title}' in stock", ['title' => $stock_item->Title] )); } } $item->ParentID = $cart->ID; $item->write(); } $this->save(); return $this; }
[ "public", "function", "addItem", "(", "$", "item", ",", "$", "customisations", "=", "[", "]", ")", "{", "$", "cart", "=", "$", "this", "->", "getCurrent", "(", ")", ";", "$", "stock_item", "=", "$", "item", "->", "FindStockItem", "(", ")", ";", "$"...
Add an item to the shopping cart. By default this should be a line item, but this method will determine if the correct object has been provided before attempting to add. @param array $item The item to add (defaults to @link LineItem) @param array $customisations (A list of @LineItemCustomisations customisations to provide) @throws ValidationException @return self
[ "Add", "an", "item", "to", "the", "shopping", "cart", ".", "By", "default", "this", "should", "be", "a", "line", "item", "but", "this", "method", "will", "determine", "if", "the", "correct", "object", "has", "been", "provided", "before", "attempting", "to"...
11e1296c095f9c2d35395d8d3b9d30e8a9db745b
https://github.com/silvercommerce/shoppingcart/blob/11e1296c095f9c2d35395d8d3b9d30e8a9db745b/src/ShoppingCartFactory.php#L220-L315
train
silvercommerce/shoppingcart
src/ShoppingCartFactory.php
ShoppingCartFactory.removeItem
public function removeItem($item) { if (!$item instanceof LineItem) { throw new ValidationException(_t( "ShoppingCart.WrongItemClass", "Item needs to be of class {class}", ["class" => LineItem::class] )); } $item->delete(); $this->save(); return $this; }
php
public function removeItem($item) { if (!$item instanceof LineItem) { throw new ValidationException(_t( "ShoppingCart.WrongItemClass", "Item needs to be of class {class}", ["class" => LineItem::class] )); } $item->delete(); $this->save(); return $this; }
[ "public", "function", "removeItem", "(", "$", "item", ")", "{", "if", "(", "!", "$", "item", "instanceof", "LineItem", ")", "{", "throw", "new", "ValidationException", "(", "_t", "(", "\"ShoppingCart.WrongItemClass\"", ",", "\"Item needs to be of class {class}\"", ...
Remove a LineItem from ShoppingCart @param LineItem $item The item to remove @return self
[ "Remove", "a", "LineItem", "from", "ShoppingCart" ]
11e1296c095f9c2d35395d8d3b9d30e8a9db745b
https://github.com/silvercommerce/shoppingcart/blob/11e1296c095f9c2d35395d8d3b9d30e8a9db745b/src/ShoppingCartFactory.php#L371-L385
train
silvercommerce/shoppingcart
src/ShoppingCartFactory.php
ShoppingCartFactory.delete
public function delete() { $cookies = $this->cookiesSupported(); $cart = $this->getCurrent(); // Only delete the cart if it has been written to the DB if ($cart->exists()) { $cart->delete(); } if ($cookies) { Cookie::force_expiry(self::COOKIE_NAME); } else { $this->getSession()->clear(self::COOKIE_NAME); } return $this; }
php
public function delete() { $cookies = $this->cookiesSupported(); $cart = $this->getCurrent(); // Only delete the cart if it has been written to the DB if ($cart->exists()) { $cart->delete(); } if ($cookies) { Cookie::force_expiry(self::COOKIE_NAME); } else { $this->getSession()->clear(self::COOKIE_NAME); } return $this; }
[ "public", "function", "delete", "(", ")", "{", "$", "cookies", "=", "$", "this", "->", "cookiesSupported", "(", ")", ";", "$", "cart", "=", "$", "this", "->", "getCurrent", "(", ")", ";", "// Only delete the cart if it has been written to the DB", "if", "(", ...
Destroy current shopping cart @return self
[ "Destroy", "current", "shopping", "cart" ]
11e1296c095f9c2d35395d8d3b9d30e8a9db745b
https://github.com/silvercommerce/shoppingcart/blob/11e1296c095f9c2d35395d8d3b9d30e8a9db745b/src/ShoppingCartFactory.php#L393-L410
train
klermonte/zerg
src/Zerg/Field/Collection.php
Collection.parse
public function parse(AbstractStream $stream) { if (!($this->dataSet instanceof DataSet)) { $this->dataSet = new DataSet; } $this->rewind(); do { $field = $this->current(); $field->setDataSet($this->getDataSet()); if ($field instanceof Conditional) { $field = $field->resolveField(); } if ($field instanceof self) { $this->dataSet->push($this->key()); $field->parse($stream); $this->dataSet->pop(); } else { $this->dataSet->setValue($this->key(), $field->parse($stream)); } $this->next(); } while ($this->valid()); if (isset($this->assert)) { $this->validate($this->dataSet->getValueByCurrentPath()); } return $this->dataSet->getData(); }
php
public function parse(AbstractStream $stream) { if (!($this->dataSet instanceof DataSet)) { $this->dataSet = new DataSet; } $this->rewind(); do { $field = $this->current(); $field->setDataSet($this->getDataSet()); if ($field instanceof Conditional) { $field = $field->resolveField(); } if ($field instanceof self) { $this->dataSet->push($this->key()); $field->parse($stream); $this->dataSet->pop(); } else { $this->dataSet->setValue($this->key(), $field->parse($stream)); } $this->next(); } while ($this->valid()); if (isset($this->assert)) { $this->validate($this->dataSet->getValueByCurrentPath()); } return $this->dataSet->getData(); }
[ "public", "function", "parse", "(", "AbstractStream", "$", "stream", ")", "{", "if", "(", "!", "(", "$", "this", "->", "dataSet", "instanceof", "DataSet", ")", ")", "{", "$", "this", "->", "dataSet", "=", "new", "DataSet", ";", "}", "$", "this", "->"...
Recursively call parse method of all children and store values in associated DataSet. @api @param AbstractStream $stream Stream from which children read. @return array Array of parsed values.
[ "Recursively", "call", "parse", "method", "of", "all", "children", "and", "store", "values", "in", "associated", "DataSet", "." ]
c5d9c52cfade1fe9169e3cbae855b49a054f04ff
https://github.com/klermonte/zerg/blob/c5d9c52cfade1fe9169e3cbae855b49a054f04ff/src/Zerg/Field/Collection.php#L47-L75
train
klermonte/zerg
src/Zerg/Field/Collection.php
Collection.initFromArray
private function initFromArray(array $fieldArray = []) { foreach ($fieldArray as $fieldName => $fieldParams) { $this->addField($fieldName, Factory::get($fieldParams)); } }
php
private function initFromArray(array $fieldArray = []) { foreach ($fieldArray as $fieldName => $fieldParams) { $this->addField($fieldName, Factory::get($fieldParams)); } }
[ "private", "function", "initFromArray", "(", "array", "$", "fieldArray", "=", "[", "]", ")", "{", "foreach", "(", "$", "fieldArray", "as", "$", "fieldName", "=>", "$", "fieldParams", ")", "{", "$", "this", "->", "addField", "(", "$", "fieldName", ",", ...
Recursively creates field instances form their declarations. @param array $fieldArray Array of declarations. @throws ConfigurationException If one of declarations are invalid.
[ "Recursively", "creates", "field", "instances", "form", "their", "declarations", "." ]
c5d9c52cfade1fe9169e3cbae855b49a054f04ff
https://github.com/klermonte/zerg/blob/c5d9c52cfade1fe9169e3cbae855b49a054f04ff/src/Zerg/Field/Collection.php#L83-L88
train
thinktomorrow/assetlibrary
src/Traits/AssetTrait.php
AssetTrait.addFile
public function addFile($file, $type = '', $locale = null, $filename = null, $keepOriginal = false): void { if ($file instanceof Traversable || is_array($file)) { $this->addFiles($file, $type, $locale, $keepOriginal); } else { $locale = $this->normalizeLocaleString($locale); if (is_string($file)) { $asset = AssetUploader::uploadFromBase64($file, $filename, $keepOriginal); } else { $asset = AssetUploader::upload($file, $filename, $keepOriginal); } if ($asset instanceof Asset) { $asset->attachToModel($this, $type, $locale); } } }
php
public function addFile($file, $type = '', $locale = null, $filename = null, $keepOriginal = false): void { if ($file instanceof Traversable || is_array($file)) { $this->addFiles($file, $type, $locale, $keepOriginal); } else { $locale = $this->normalizeLocaleString($locale); if (is_string($file)) { $asset = AssetUploader::uploadFromBase64($file, $filename, $keepOriginal); } else { $asset = AssetUploader::upload($file, $filename, $keepOriginal); } if ($asset instanceof Asset) { $asset->attachToModel($this, $type, $locale); } } }
[ "public", "function", "addFile", "(", "$", "file", ",", "$", "type", "=", "''", ",", "$", "locale", "=", "null", ",", "$", "filename", "=", "null", ",", "$", "keepOriginal", "=", "false", ")", ":", "void", "{", "if", "(", "$", "file", "instanceof",...
Adds a file to this model, accepts a type and locale to be saved with the file. @param $file @param string $type @param string|null $locale @param null $filename @param bool $keepOriginal @throws \Spatie\MediaLibrary\Exceptions\FileCannotBeAdded @throws \Thinktomorrow\AssetLibrary\Exceptions\AssetUploadException
[ "Adds", "a", "file", "to", "this", "model", "accepts", "a", "type", "and", "locale", "to", "be", "saved", "with", "the", "file", "." ]
606c14924dc03b858d88bcc47668038365f717cf
https://github.com/thinktomorrow/assetlibrary/blob/606c14924dc03b858d88bcc47668038365f717cf/src/Traits/AssetTrait.php#L82-L99
train
thinktomorrow/assetlibrary
src/Traits/AssetTrait.php
AssetTrait.addFiles
public function addFiles($files, $type = '', $locale = null, $keepOriginal = false): void { $files = (array) $files; $locale = $this->normalizeLocaleString($locale); if (is_string(array_values($files)[0])) { foreach ($files as $filename => $file) { $this->addFile($file, $type, $locale, $filename, $keepOriginal); } } else { foreach ($files as $filename => $file) { $this->addFile($file, $type, $locale, $filename, $keepOriginal); } } }
php
public function addFiles($files, $type = '', $locale = null, $keepOriginal = false): void { $files = (array) $files; $locale = $this->normalizeLocaleString($locale); if (is_string(array_values($files)[0])) { foreach ($files as $filename => $file) { $this->addFile($file, $type, $locale, $filename, $keepOriginal); } } else { foreach ($files as $filename => $file) { $this->addFile($file, $type, $locale, $filename, $keepOriginal); } } }
[ "public", "function", "addFiles", "(", "$", "files", ",", "$", "type", "=", "''", ",", "$", "locale", "=", "null", ",", "$", "keepOriginal", "=", "false", ")", ":", "void", "{", "$", "files", "=", "(", "array", ")", "$", "files", ";", "$", "local...
Adds multiple files to this model, accepts a type and locale to be saved with the file. @param $files @param string $type @param string|null $locale @param bool $keepOriginal @throws \Spatie\MediaLibrary\Exceptions\FileCannotBeAdded @throws \Thinktomorrow\AssetLibrary\Exceptions\AssetUploadException
[ "Adds", "multiple", "files", "to", "this", "model", "accepts", "a", "type", "and", "locale", "to", "be", "saved", "with", "the", "file", "." ]
606c14924dc03b858d88bcc47668038365f717cf
https://github.com/thinktomorrow/assetlibrary/blob/606c14924dc03b858d88bcc47668038365f717cf/src/Traits/AssetTrait.php#L111-L125
train
thinktomorrow/assetlibrary
src/Traits/AssetTrait.php
AssetTrait.replaceAsset
public function replaceAsset($replace, $with) { $old = $this->assets()->findOrFail($replace); $this->assets()->detach($old->id); $old->delete(); $this->addFile(Asset::findOrFail($with), $old->pivot->type, $old->pivot->locale); }
php
public function replaceAsset($replace, $with) { $old = $this->assets()->findOrFail($replace); $this->assets()->detach($old->id); $old->delete(); $this->addFile(Asset::findOrFail($with), $old->pivot->type, $old->pivot->locale); }
[ "public", "function", "replaceAsset", "(", "$", "replace", ",", "$", "with", ")", "{", "$", "old", "=", "$", "this", "->", "assets", "(", ")", "->", "findOrFail", "(", "$", "replace", ")", ";", "$", "this", "->", "assets", "(", ")", "->", "detach",...
Remove the asset and attaches a new one. @param $replace @param $with @throws \Spatie\MediaLibrary\Exceptions\FileCannotBeAdded @throws \Thinktomorrow\AssetLibrary\Exceptions\AssetUploadException
[ "Remove", "the", "asset", "and", "attaches", "a", "new", "one", "." ]
606c14924dc03b858d88bcc47668038365f717cf
https://github.com/thinktomorrow/assetlibrary/blob/606c14924dc03b858d88bcc47668038365f717cf/src/Traits/AssetTrait.php#L157-L165
train
Speelpenning-nl/laravel-authentication
src/Console/Commands/RegisterUser.php
RegisterUser.collectInput
protected function collectInput() { $password = $this->generateRandomPassword(); return [ 'name' => $this->argument('name') ? $this->argument('name') : '', 'email' => $this->argument('email'), 'password' => $password, 'password_confirmation' => $password, ]; }
php
protected function collectInput() { $password = $this->generateRandomPassword(); return [ 'name' => $this->argument('name') ? $this->argument('name') : '', 'email' => $this->argument('email'), 'password' => $password, 'password_confirmation' => $password, ]; }
[ "protected", "function", "collectInput", "(", ")", "{", "$", "password", "=", "$", "this", "->", "generateRandomPassword", "(", ")", ";", "return", "[", "'name'", "=>", "$", "this", "->", "argument", "(", "'name'", ")", "?", "$", "this", "->", "argument"...
Returns an array with all required input. @return array
[ "Returns", "an", "array", "with", "all", "required", "input", "." ]
44671afa8d654a9c6281cce13353d95126478d8b
https://github.com/Speelpenning-nl/laravel-authentication/blob/44671afa8d654a9c6281cce13353d95126478d8b/src/Console/Commands/RegisterUser.php#L60-L70
train
Speelpenning-nl/laravel-authentication
src/Console/Commands/RegisterUser.php
RegisterUser.registerUser
protected function registerUser(array $input) { $this->dispatch(new RegisterUserJob(array_get($input, 'name'), array_get($input, 'email'), array_get($input, 'password'))); $this->info(trans('authentication::user.console.created', $input)); }
php
protected function registerUser(array $input) { $this->dispatch(new RegisterUserJob(array_get($input, 'name'), array_get($input, 'email'), array_get($input, 'password'))); $this->info(trans('authentication::user.console.created', $input)); }
[ "protected", "function", "registerUser", "(", "array", "$", "input", ")", "{", "$", "this", "->", "dispatch", "(", "new", "RegisterUserJob", "(", "array_get", "(", "$", "input", ",", "'name'", ")", ",", "array_get", "(", "$", "input", ",", "'email'", ")"...
Performs the user registration. @param array $input
[ "Performs", "the", "user", "registration", "." ]
44671afa8d654a9c6281cce13353d95126478d8b
https://github.com/Speelpenning-nl/laravel-authentication/blob/44671afa8d654a9c6281cce13353d95126478d8b/src/Console/Commands/RegisterUser.php#L104-L110
train
davedevelopment/dspec
src/DSpec/Reporter.php
Reporter.exampleFailed
public function exampleFailed(Example $example) { $this->failures[] = $example; $event = new ExampleFailEvent($example); $this->dispatcher->dispatch(Events::EXAMPLE_FAIL, $event); }
php
public function exampleFailed(Example $example) { $this->failures[] = $example; $event = new ExampleFailEvent($example); $this->dispatcher->dispatch(Events::EXAMPLE_FAIL, $event); }
[ "public", "function", "exampleFailed", "(", "Example", "$", "example", ")", "{", "$", "this", "->", "failures", "[", "]", "=", "$", "example", ";", "$", "event", "=", "new", "ExampleFailEvent", "(", "$", "example", ")", ";", "$", "this", "->", "dispatc...
An example failed @param Example $example
[ "An", "example", "failed" ]
6077b1d213dc09f1fbcf7b260f3926a7019a0618
https://github.com/davedevelopment/dspec/blob/6077b1d213dc09f1fbcf7b260f3926a7019a0618/src/DSpec/Reporter.php#L40-L45
train
davedevelopment/dspec
src/DSpec/Reporter.php
Reporter.examplePassed
public function examplePassed(Example $example) { $this->passes[] = $example; $event = new ExamplePassEvent($example); $this->dispatcher->dispatch(Events::EXAMPLE_PASS, $event); }
php
public function examplePassed(Example $example) { $this->passes[] = $example; $event = new ExamplePassEvent($example); $this->dispatcher->dispatch(Events::EXAMPLE_PASS, $event); }
[ "public", "function", "examplePassed", "(", "Example", "$", "example", ")", "{", "$", "this", "->", "passes", "[", "]", "=", "$", "example", ";", "$", "event", "=", "new", "ExamplePassEvent", "(", "$", "example", ")", ";", "$", "this", "->", "dispatche...
An example passed @param Example $example
[ "An", "example", "passed" ]
6077b1d213dc09f1fbcf7b260f3926a7019a0618
https://github.com/davedevelopment/dspec/blob/6077b1d213dc09f1fbcf7b260f3926a7019a0618/src/DSpec/Reporter.php#L52-L57
train
davedevelopment/dspec
src/DSpec/Reporter.php
Reporter.examplePending
public function examplePending(Example $example) { $this->pending[] = $example; $event = new ExamplePendEvent($example); $this->dispatcher->dispatch(Events::EXAMPLE_PEND, $event); }
php
public function examplePending(Example $example) { $this->pending[] = $example; $event = new ExamplePendEvent($example); $this->dispatcher->dispatch(Events::EXAMPLE_PEND, $event); }
[ "public", "function", "examplePending", "(", "Example", "$", "example", ")", "{", "$", "this", "->", "pending", "[", "]", "=", "$", "example", ";", "$", "event", "=", "new", "ExamplePendEvent", "(", "$", "example", ")", ";", "$", "this", "->", "dispatc...
An example is pending @param Example $example
[ "An", "example", "is", "pending" ]
6077b1d213dc09f1fbcf7b260f3926a7019a0618
https://github.com/davedevelopment/dspec/blob/6077b1d213dc09f1fbcf7b260f3926a7019a0618/src/DSpec/Reporter.php#L64-L69
train
davedevelopment/dspec
src/DSpec/Reporter.php
Reporter.exampleSkipped
public function exampleSkipped(Example $example) { $this->skipped[] = $example; $event = new ExampleSkipEvent($example); $this->dispatcher->dispatch(Events::EXAMPLE_SKIP, $event); }
php
public function exampleSkipped(Example $example) { $this->skipped[] = $example; $event = new ExampleSkipEvent($example); $this->dispatcher->dispatch(Events::EXAMPLE_SKIP, $event); }
[ "public", "function", "exampleSkipped", "(", "Example", "$", "example", ")", "{", "$", "this", "->", "skipped", "[", "]", "=", "$", "example", ";", "$", "event", "=", "new", "ExampleSkipEvent", "(", "$", "example", ")", ";", "$", "this", "->", "dispatc...
An example is skipped @param Example $example
[ "An", "example", "is", "skipped" ]
6077b1d213dc09f1fbcf7b260f3926a7019a0618
https://github.com/davedevelopment/dspec/blob/6077b1d213dc09f1fbcf7b260f3926a7019a0618/src/DSpec/Reporter.php#L76-L81
train
koolkode/async
src/OptimizationLoader.php
OptimizationLoader.optimize
public static function optimize(string $key, string $typeName, string $optimizedType): void { self::$replacements[$typeName][$key] = $optimizedType; }
php
public static function optimize(string $key, string $typeName, string $optimizedType): void { self::$replacements[$typeName][$key] = $optimizedType; }
[ "public", "static", "function", "optimize", "(", "string", "$", "key", ",", "string", "$", "typeName", ",", "string", "$", "optimizedType", ")", ":", "void", "{", "self", "::", "$", "replacements", "[", "$", "typeName", "]", "[", "$", "key", "]", "=", ...
Register an optimized version of a class. @param string $key Name being used to activate the optimization in KOOLKODE_ASYNC_OPTIMIZATIONS. @param string $typeName Name of the class to be replaced. @param string $optimizedType Name of the optimized replacement class.
[ "Register", "an", "optimized", "version", "of", "a", "class", "." ]
9c985dcdd3b328323826dd4254d9f2e5aea0b75b
https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/OptimizationLoader.php#L39-L42
train
koolkode/async
src/OptimizationLoader.php
OptimizationLoader.autoload
public static function autoload(string $typeName): bool { static $enabled; if (\defined('KOOLKODE_ASYNC_OPTIMIZATIONS')) { if ($enabled === null) { $enabled = \array_map('trim', \explode(',', \strtolower(\KOOLKODE_ASYNC_OPTIMIZATIONS))); } if (isset(self::$replacements[$typeName])) { foreach ($enabled as $key) { if (isset(self::$replacements[$typeName][$key])) { return \class_alias(self::$replacements[$typeName][$key], $typeName, true); } } } } return false; }
php
public static function autoload(string $typeName): bool { static $enabled; if (\defined('KOOLKODE_ASYNC_OPTIMIZATIONS')) { if ($enabled === null) { $enabled = \array_map('trim', \explode(',', \strtolower(\KOOLKODE_ASYNC_OPTIMIZATIONS))); } if (isset(self::$replacements[$typeName])) { foreach ($enabled as $key) { if (isset(self::$replacements[$typeName][$key])) { return \class_alias(self::$replacements[$typeName][$key], $typeName, true); } } } } return false; }
[ "public", "static", "function", "autoload", "(", "string", "$", "typeName", ")", ":", "bool", "{", "static", "$", "enabled", ";", "if", "(", "\\", "defined", "(", "'KOOLKODE_ASYNC_OPTIMIZATIONS'", ")", ")", "{", "if", "(", "$", "enabled", "===", "null", ...
Triggered by SPL autoload when a class needs to be loaded.
[ "Triggered", "by", "SPL", "autoload", "when", "a", "class", "needs", "to", "be", "loaded", "." ]
9c985dcdd3b328323826dd4254d9f2e5aea0b75b
https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/OptimizationLoader.php#L58-L77
train
CoandaCMS/coanda-core
src/CoandaCMS/Coanda/History/Repositories/Eloquent/EloquentHistoryRepository.php
EloquentHistoryRepository.add
public function add($for, $for_id, $user_id, $action, $data = '') { $history = new $this->model; $history->for = $for; $history->for_id = $for_id; $history->user_id = $user_id; $history->action = $action; $history->data = is_array($data) ? json_encode($data) : $data; $history->save(); return $history; }
php
public function add($for, $for_id, $user_id, $action, $data = '') { $history = new $this->model; $history->for = $for; $history->for_id = $for_id; $history->user_id = $user_id; $history->action = $action; $history->data = is_array($data) ? json_encode($data) : $data; $history->save(); return $history; }
[ "public", "function", "add", "(", "$", "for", ",", "$", "for_id", ",", "$", "user_id", ",", "$", "action", ",", "$", "data", "=", "''", ")", "{", "$", "history", "=", "new", "$", "this", "->", "model", ";", "$", "history", "->", "for", "=", "$"...
Adds a new history record @param string $for @param integer $for_id @param integer $user_id @param $action @param mixed $data @return mixed
[ "Adds", "a", "new", "history", "record" ]
b7d68f23418dada1222fad141e93fe8480c4b24f
https://github.com/CoandaCMS/coanda-core/blob/b7d68f23418dada1222fad141e93fe8480c4b24f/src/CoandaCMS/Coanda/History/Repositories/Eloquent/EloquentHistoryRepository.php#L49-L61
train
CoandaCMS/coanda-core
src/CoandaCMS/Coanda/History/Repositories/Eloquent/EloquentHistoryRepository.php
EloquentHistoryRepository.get
public function get($for, $for_id, $limit = false) { return $this->model->whereFor($for)->whereForId($for_id)->orderBy('created_at', 'desc')->take($limit)->get(); }
php
public function get($for, $for_id, $limit = false) { return $this->model->whereFor($for)->whereForId($for_id)->orderBy('created_at', 'desc')->take($limit)->get(); }
[ "public", "function", "get", "(", "$", "for", ",", "$", "for_id", ",", "$", "limit", "=", "false", ")", "{", "return", "$", "this", "->", "model", "->", "whereFor", "(", "$", "for", ")", "->", "whereForId", "(", "$", "for_id", ")", "->", "orderBy",...
Returns all the history for a specified for and for_id @param string $for @param integer $for_id @param bool $limit @return mixed
[ "Returns", "all", "the", "history", "for", "a", "specified", "for", "and", "for_id" ]
b7d68f23418dada1222fad141e93fe8480c4b24f
https://github.com/CoandaCMS/coanda-core/blob/b7d68f23418dada1222fad141e93fe8480c4b24f/src/CoandaCMS/Coanda/History/Repositories/Eloquent/EloquentHistoryRepository.php#L70-L73
train
Roave/RoaveDeveloperTools
src/Roave/DeveloperTools/Renderer/BaseAggregateInspectionRenderer.php
BaseAggregateInspectionRenderer.expandAggregateInspectionData
protected function expandAggregateInspectionData(InspectionInterface $inspection) { if ($inspection instanceof AggregateInspection) { return array_map( function (InspectionInterface $inspection) { return [ static::PARAM_INSPECTION => $inspection, static::PARAM_INSPECTION_DATA => $this->expandAggregateInspectionData($inspection), static::PARAM_INSPECTION_CLASS => get_class($inspection), ]; }, $inspection->getInspectionData() ); } return $inspection->getInspectionData(); }
php
protected function expandAggregateInspectionData(InspectionInterface $inspection) { if ($inspection instanceof AggregateInspection) { return array_map( function (InspectionInterface $inspection) { return [ static::PARAM_INSPECTION => $inspection, static::PARAM_INSPECTION_DATA => $this->expandAggregateInspectionData($inspection), static::PARAM_INSPECTION_CLASS => get_class($inspection), ]; }, $inspection->getInspectionData() ); } return $inspection->getInspectionData(); }
[ "protected", "function", "expandAggregateInspectionData", "(", "InspectionInterface", "$", "inspection", ")", "{", "if", "(", "$", "inspection", "instanceof", "AggregateInspection", ")", "{", "return", "array_map", "(", "function", "(", "InspectionInterface", "$", "in...
Expand the data from an aggregate inspection recursively, providing useful data for the produced view model @param InspectionInterface $inspection @return array|mixed[]|\Traversable
[ "Expand", "the", "data", "from", "an", "aggregate", "inspection", "recursively", "providing", "useful", "data", "for", "the", "produced", "view", "model" ]
424285eb861c9df7891ce7c6e66a21756eecd81c
https://github.com/Roave/RoaveDeveloperTools/blob/424285eb861c9df7891ce7c6e66a21756eecd81c/src/Roave/DeveloperTools/Renderer/BaseAggregateInspectionRenderer.php#L107-L123
train
MetaModels/attribute_timestamp
src/EventListener/BootListener.php
BootListener.handleEncodePropertyValueFromWidget
public function handleEncodePropertyValueFromWidget(EncodePropertyValueFromWidgetEvent $event) { $attribute = $this->getSupportedAttribute($event); if (!$attribute) { return; } $date = \DateTime::createFromFormat($attribute->getDateTimeFormatString(), $event->getValue()); if ($date) { $event->setValue($date->getTimestamp()); } }
php
public function handleEncodePropertyValueFromWidget(EncodePropertyValueFromWidgetEvent $event) { $attribute = $this->getSupportedAttribute($event); if (!$attribute) { return; } $date = \DateTime::createFromFormat($attribute->getDateTimeFormatString(), $event->getValue()); if ($date) { $event->setValue($date->getTimestamp()); } }
[ "public", "function", "handleEncodePropertyValueFromWidget", "(", "EncodePropertyValueFromWidgetEvent", "$", "event", ")", "{", "$", "attribute", "=", "$", "this", "->", "getSupportedAttribute", "(", "$", "event", ")", ";", "if", "(", "!", "$", "attribute", ")", ...
Encode an timestamp attribute value from a widget value. @param EncodePropertyValueFromWidgetEvent $event The subscribed event. @return void
[ "Encode", "an", "timestamp", "attribute", "value", "from", "a", "widget", "value", "." ]
ba2e5e946e752fc269cc59b62a9a3c8fbf8768c3
https://github.com/MetaModels/attribute_timestamp/blob/ba2e5e946e752fc269cc59b62a9a3c8fbf8768c3/src/EventListener/BootListener.php#L44-L56
train
MetaModels/attribute_timestamp
src/EventListener/BootListener.php
BootListener.handleDecodePropertyValueForWidgetEvent
public function handleDecodePropertyValueForWidgetEvent(DecodePropertyValueForWidgetEvent $event) { $attribute = $this->getSupportedAttribute($event); if (!$attribute) { return; } $dispatcher = $event->getEnvironment()->getEventDispatcher(); $value = $event->getValue(); if (\is_numeric($value)) { $dateEvent = new ParseDateEvent($value, $attribute->getDateTimeFormatString()); $dispatcher->dispatch(ContaoEvents::DATE_PARSE, $dateEvent); $event->setValue($dateEvent->getResult()); } }
php
public function handleDecodePropertyValueForWidgetEvent(DecodePropertyValueForWidgetEvent $event) { $attribute = $this->getSupportedAttribute($event); if (!$attribute) { return; } $dispatcher = $event->getEnvironment()->getEventDispatcher(); $value = $event->getValue(); if (\is_numeric($value)) { $dateEvent = new ParseDateEvent($value, $attribute->getDateTimeFormatString()); $dispatcher->dispatch(ContaoEvents::DATE_PARSE, $dateEvent); $event->setValue($dateEvent->getResult()); } }
[ "public", "function", "handleDecodePropertyValueForWidgetEvent", "(", "DecodePropertyValueForWidgetEvent", "$", "event", ")", "{", "$", "attribute", "=", "$", "this", "->", "getSupportedAttribute", "(", "$", "event", ")", ";", "if", "(", "!", "$", "attribute", ")"...
Decode an timestamp attribute value for a widget value. @param DecodePropertyValueForWidgetEvent $event The subscribed event. @return void
[ "Decode", "an", "timestamp", "attribute", "value", "for", "a", "widget", "value", "." ]
ba2e5e946e752fc269cc59b62a9a3c8fbf8768c3
https://github.com/MetaModels/attribute_timestamp/blob/ba2e5e946e752fc269cc59b62a9a3c8fbf8768c3/src/EventListener/BootListener.php#L65-L81
train