id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
25,300
horntell/php-sdk
lib/guzzle/GuzzleHttp/Adapter/Curl/MultiAdapter.php
MultiAdapter.releaseMultiHandle
private function releaseMultiHandle($handle, $maxHandles) { $id = (int) $handle; if (count($this->multiHandles) <= $maxHandles) { $this->multiOwned[$id] = false; } elseif (isset($this->multiHandles[$id], $this->multiOwned[$id])) { // Prune excessive handles curl_multi_close($this->multiHandles[$id]); unset($this->multiHandles[$id], $this->multiOwned[$id]); } }
php
private function releaseMultiHandle($handle, $maxHandles) { $id = (int) $handle; if (count($this->multiHandles) <= $maxHandles) { $this->multiOwned[$id] = false; } elseif (isset($this->multiHandles[$id], $this->multiOwned[$id])) { // Prune excessive handles curl_multi_close($this->multiHandles[$id]); unset($this->multiHandles[$id], $this->multiOwned[$id]); } }
[ "private", "function", "releaseMultiHandle", "(", "$", "handle", ",", "$", "maxHandles", ")", "{", "$", "id", "=", "(", "int", ")", "$", "handle", ";", "if", "(", "count", "(", "$", "this", "->", "multiHandles", ")", "<=", "$", "maxHandles", ")", "{", "$", "this", "->", "multiOwned", "[", "$", "id", "]", "=", "false", ";", "}", "elseif", "(", "isset", "(", "$", "this", "->", "multiHandles", "[", "$", "id", "]", ",", "$", "this", "->", "multiOwned", "[", "$", "id", "]", ")", ")", "{", "// Prune excessive handles", "curl_multi_close", "(", "$", "this", "->", "multiHandles", "[", "$", "id", "]", ")", ";", "unset", "(", "$", "this", "->", "multiHandles", "[", "$", "id", "]", ",", "$", "this", "->", "multiOwned", "[", "$", "id", "]", ")", ";", "}", "}" ]
Releases a curl_multi handle back into the cache and removes excess cache @param resource $handle Curl multi handle to remove @param int $maxHandles (Optional) Maximum number of existing multiHandles to allow before pruning.
[ "Releases", "a", "curl_multi", "handle", "back", "into", "the", "cache", "and", "removes", "excess", "cache" ]
e5205e9396a21b754d5651a8aa5898da5922a1b7
https://github.com/horntell/php-sdk/blob/e5205e9396a21b754d5651a8aa5898da5922a1b7/lib/guzzle/GuzzleHttp/Adapter/Curl/MultiAdapter.php#L294-L305
25,301
Wedeto/FileFormats
src/AbstractReader.php
AbstractReader.read
public function read($param) { if ($param instanceof File) return $this->readFile($param->getFullPath()); if (is_resource($param)) return $this->readFileHandle($param); if (!is_string($param)) throw new \InvalidArgumentException("Cannot read argument: " . WF::str($param)); if (strlen($param) < 1024 && file_exists($param)) return $this->readFile($param); return $this->readString($param); }
php
public function read($param) { if ($param instanceof File) return $this->readFile($param->getFullPath()); if (is_resource($param)) return $this->readFileHandle($param); if (!is_string($param)) throw new \InvalidArgumentException("Cannot read argument: " . WF::str($param)); if (strlen($param) < 1024 && file_exists($param)) return $this->readFile($param); return $this->readString($param); }
[ "public", "function", "read", "(", "$", "param", ")", "{", "if", "(", "$", "param", "instanceof", "File", ")", "return", "$", "this", "->", "readFile", "(", "$", "param", "->", "getFullPath", "(", ")", ")", ";", "if", "(", "is_resource", "(", "$", "param", ")", ")", "return", "$", "this", "->", "readFileHandle", "(", "$", "param", ")", ";", "if", "(", "!", "is_string", "(", "$", "param", ")", ")", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Cannot read argument: \"", ".", "WF", "::", "str", "(", "$", "param", ")", ")", ";", "if", "(", "strlen", "(", "$", "param", ")", "<", "1024", "&&", "file_exists", "(", "$", "param", ")", ")", "return", "$", "this", "->", "readFile", "(", "$", "param", ")", ";", "return", "$", "this", "->", "readString", "(", "$", "param", ")", ";", "}" ]
Read provided data. The method auto-detects if it is a file, a resource or a string that contains the formatted data. @param mixed $param The data to read @return array The read data @throws InvalidArgumentException When an unrecognized argument is provided @throws Wedeto\IO\IOException When reading fails
[ "Read", "provided", "data", ".", "The", "method", "auto", "-", "detects", "if", "it", "is", "a", "file", "a", "resource", "or", "a", "string", "that", "contains", "the", "formatted", "data", "." ]
65b71fbd38a2ee6b504622aca4f4047ce9d31e9f
https://github.com/Wedeto/FileFormats/blob/65b71fbd38a2ee6b504622aca4f4047ce9d31e9f/src/AbstractReader.php#L52-L67
25,302
Wedeto/FileFormats
src/AbstractReader.php
AbstractReader.readFile
public function readFile(string $file_name) { $contents = @file_get_contents($file_name); if ($contents === false) throw new IOException("Failed to read file contents"); $contents = Encoding::removeBOM($contents); return $this->readString(file_get_contents($file_name)); }
php
public function readFile(string $file_name) { $contents = @file_get_contents($file_name); if ($contents === false) throw new IOException("Failed to read file contents"); $contents = Encoding::removeBOM($contents); return $this->readString(file_get_contents($file_name)); }
[ "public", "function", "readFile", "(", "string", "$", "file_name", ")", "{", "$", "contents", "=", "@", "file_get_contents", "(", "$", "file_name", ")", ";", "if", "(", "$", "contents", "===", "false", ")", "throw", "new", "IOException", "(", "\"Failed to read file contents\"", ")", ";", "$", "contents", "=", "Encoding", "::", "removeBOM", "(", "$", "contents", ")", ";", "return", "$", "this", "->", "readString", "(", "file_get_contents", "(", "$", "file_name", ")", ")", ";", "}" ]
Read data from a file @param string $file_name The file to read @return array The read data @throws Wedeto\IO\IOException On read errors
[ "Read", "data", "from", "a", "file" ]
65b71fbd38a2ee6b504622aca4f4047ce9d31e9f
https://github.com/Wedeto/FileFormats/blob/65b71fbd38a2ee6b504622aca4f4047ce9d31e9f/src/AbstractReader.php#L75-L83
25,303
Wedeto/FileFormats
src/AbstractReader.php
AbstractReader.readFileHandle
public function readFileHandle($file_handle) { if (!is_resource($file_handle)) throw new \InvalidArgumentException("No file handle was provided"); $contents = stream_get_contents($file_handle); $contents = Encoding::removeBOM($contents); return $this->readString($contents); }
php
public function readFileHandle($file_handle) { if (!is_resource($file_handle)) throw new \InvalidArgumentException("No file handle was provided"); $contents = stream_get_contents($file_handle); $contents = Encoding::removeBOM($contents); return $this->readString($contents); }
[ "public", "function", "readFileHandle", "(", "$", "file_handle", ")", "{", "if", "(", "!", "is_resource", "(", "$", "file_handle", ")", ")", "throw", "new", "\\", "InvalidArgumentException", "(", "\"No file handle was provided\"", ")", ";", "$", "contents", "=", "stream_get_contents", "(", "$", "file_handle", ")", ";", "$", "contents", "=", "Encoding", "::", "removeBOM", "(", "$", "contents", ")", ";", "return", "$", "this", "->", "readString", "(", "$", "contents", ")", ";", "}" ]
Read from a file handle to an open file or resource @param resource $file_handle The resource to read @throws Wedeto\IO\IOException On read errors
[ "Read", "from", "a", "file", "handle", "to", "an", "open", "file", "or", "resource" ]
65b71fbd38a2ee6b504622aca4f4047ce9d31e9f
https://github.com/Wedeto/FileFormats/blob/65b71fbd38a2ee6b504622aca4f4047ce9d31e9f/src/AbstractReader.php#L90-L99
25,304
dms-org/common.structure
src/Table/TableData.php
TableData.hasColumn
public function hasColumn($columnKey) : bool { $this->validateColumnKey(__METHOD__, $columnKey); $this->loadColumns(); $columnHash = ValueHasher::hash($columnKey); return isset($this->columns[$columnHash]); }
php
public function hasColumn($columnKey) : bool { $this->validateColumnKey(__METHOD__, $columnKey); $this->loadColumns(); $columnHash = ValueHasher::hash($columnKey); return isset($this->columns[$columnHash]); }
[ "public", "function", "hasColumn", "(", "$", "columnKey", ")", ":", "bool", "{", "$", "this", "->", "validateColumnKey", "(", "__METHOD__", ",", "$", "columnKey", ")", ";", "$", "this", "->", "loadColumns", "(", ")", ";", "$", "columnHash", "=", "ValueHasher", "::", "hash", "(", "$", "columnKey", ")", ";", "return", "isset", "(", "$", "this", "->", "columns", "[", "$", "columnHash", "]", ")", ";", "}" ]
Returns whether the table data contains a column with the supplied key. @param mixed $columnKey @return bool @throws TypeMismatchException
[ "Returns", "whether", "the", "table", "data", "contains", "a", "column", "with", "the", "supplied", "key", "." ]
23f122182f60df5ec847047a81a39c8aab019ff1
https://github.com/dms-org/common.structure/blob/23f122182f60df5ec847047a81a39c8aab019ff1/src/Table/TableData.php#L230-L238
25,305
dms-org/common.structure
src/Table/TableData.php
TableData.getColumn
public function getColumn($columnKey) : TableDataColumn { $this->validateColumnKey(__METHOD__, $columnKey); $this->loadColumns(); $columnHash = ValueHasher::hash($columnKey); if (!isset($this->columns[$columnHash])) { throw InvalidArgumentException::format( 'Invalid column key supplied to %s: expecting one of hashes (%s), value with \'%s\' hash given', __METHOD__, Debug::formatValues(array_keys($this->columns)), $columnHash ); } return $this->columns[$columnHash]; }
php
public function getColumn($columnKey) : TableDataColumn { $this->validateColumnKey(__METHOD__, $columnKey); $this->loadColumns(); $columnHash = ValueHasher::hash($columnKey); if (!isset($this->columns[$columnHash])) { throw InvalidArgumentException::format( 'Invalid column key supplied to %s: expecting one of hashes (%s), value with \'%s\' hash given', __METHOD__, Debug::formatValues(array_keys($this->columns)), $columnHash ); } return $this->columns[$columnHash]; }
[ "public", "function", "getColumn", "(", "$", "columnKey", ")", ":", "TableDataColumn", "{", "$", "this", "->", "validateColumnKey", "(", "__METHOD__", ",", "$", "columnKey", ")", ";", "$", "this", "->", "loadColumns", "(", ")", ";", "$", "columnHash", "=", "ValueHasher", "::", "hash", "(", "$", "columnKey", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "columns", "[", "$", "columnHash", "]", ")", ")", "{", "throw", "InvalidArgumentException", "::", "format", "(", "'Invalid column key supplied to %s: expecting one of hashes (%s), value with \\'%s\\' hash given'", ",", "__METHOD__", ",", "Debug", "::", "formatValues", "(", "array_keys", "(", "$", "this", "->", "columns", ")", ")", ",", "$", "columnHash", ")", ";", "}", "return", "$", "this", "->", "columns", "[", "$", "columnHash", "]", ";", "}" ]
Gets the table column with the supplied key. @param mixed $columnKey @return TableDataColumn @throws InvalidArgumentException @throws TypeMismatchException
[ "Gets", "the", "table", "column", "with", "the", "supplied", "key", "." ]
23f122182f60df5ec847047a81a39c8aab019ff1
https://github.com/dms-org/common.structure/blob/23f122182f60df5ec847047a81a39c8aab019ff1/src/Table/TableData.php#L249-L264
25,306
dms-org/common.structure
src/Table/TableData.php
TableData.hasRow
public function hasRow($rowKey) : bool { $this->validateRowKey(__METHOD__, $rowKey); $this->loadRows(); $rowHash = ValueHasher::hash($rowKey); return isset($this->rows[$rowHash]); }
php
public function hasRow($rowKey) : bool { $this->validateRowKey(__METHOD__, $rowKey); $this->loadRows(); $rowHash = ValueHasher::hash($rowKey); return isset($this->rows[$rowHash]); }
[ "public", "function", "hasRow", "(", "$", "rowKey", ")", ":", "bool", "{", "$", "this", "->", "validateRowKey", "(", "__METHOD__", ",", "$", "rowKey", ")", ";", "$", "this", "->", "loadRows", "(", ")", ";", "$", "rowHash", "=", "ValueHasher", "::", "hash", "(", "$", "rowKey", ")", ";", "return", "isset", "(", "$", "this", "->", "rows", "[", "$", "rowHash", "]", ")", ";", "}" ]
Returns whether the table data contains a row with the supplied key. @param mixed $rowKey @return bool @throws TypeMismatchException
[ "Returns", "whether", "the", "table", "data", "contains", "a", "row", "with", "the", "supplied", "key", "." ]
23f122182f60df5ec847047a81a39c8aab019ff1
https://github.com/dms-org/common.structure/blob/23f122182f60df5ec847047a81a39c8aab019ff1/src/Table/TableData.php#L274-L282
25,307
dms-org/common.structure
src/Table/TableData.php
TableData.getRow
public function getRow($rowKey) : TableDataRow { $this->validateRowKey(__METHOD__, $rowKey); $this->loadRows(); $rowHash = ValueHasher::hash($rowKey); if (!isset($this->rows[$rowHash])) { throw InvalidArgumentException::format( 'Invalid row key supplied to %s: expecting one of hashes (%s), value with \'%s\' hash given', __METHOD__, Debug::formatValues(array_keys($this->rows)), $rowHash ); } return $this->rows[$rowHash]; }
php
public function getRow($rowKey) : TableDataRow { $this->validateRowKey(__METHOD__, $rowKey); $this->loadRows(); $rowHash = ValueHasher::hash($rowKey); if (!isset($this->rows[$rowHash])) { throw InvalidArgumentException::format( 'Invalid row key supplied to %s: expecting one of hashes (%s), value with \'%s\' hash given', __METHOD__, Debug::formatValues(array_keys($this->rows)), $rowHash ); } return $this->rows[$rowHash]; }
[ "public", "function", "getRow", "(", "$", "rowKey", ")", ":", "TableDataRow", "{", "$", "this", "->", "validateRowKey", "(", "__METHOD__", ",", "$", "rowKey", ")", ";", "$", "this", "->", "loadRows", "(", ")", ";", "$", "rowHash", "=", "ValueHasher", "::", "hash", "(", "$", "rowKey", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "rows", "[", "$", "rowHash", "]", ")", ")", "{", "throw", "InvalidArgumentException", "::", "format", "(", "'Invalid row key supplied to %s: expecting one of hashes (%s), value with \\'%s\\' hash given'", ",", "__METHOD__", ",", "Debug", "::", "formatValues", "(", "array_keys", "(", "$", "this", "->", "rows", ")", ")", ",", "$", "rowHash", ")", ";", "}", "return", "$", "this", "->", "rows", "[", "$", "rowHash", "]", ";", "}" ]
Gets the table row with the supplied key. @param mixed $rowKey @return TableDataRow @throws InvalidArgumentException @throws TypeMismatchException
[ "Gets", "the", "table", "row", "with", "the", "supplied", "key", "." ]
23f122182f60df5ec847047a81a39c8aab019ff1
https://github.com/dms-org/common.structure/blob/23f122182f60df5ec847047a81a39c8aab019ff1/src/Table/TableData.php#L293-L308
25,308
dms-org/common.structure
src/Table/TableData.php
TableData.hasCell
public function hasCell($columnKey, $rowKey) : bool { $this->validateColumnKey(__METHOD__, $columnKey); $this->validateRowKey(__METHOD__, $rowKey); $this->loadColumns(); $this->loadRows(); $columnHash = ValueHasher::hash($columnKey); if (!isset($this->columns[$columnHash])) { return false; } $rowHash = ValueHasher::hash($rowKey); if (!isset($this->rows[$rowHash])) { return false; } return true; }
php
public function hasCell($columnKey, $rowKey) : bool { $this->validateColumnKey(__METHOD__, $columnKey); $this->validateRowKey(__METHOD__, $rowKey); $this->loadColumns(); $this->loadRows(); $columnHash = ValueHasher::hash($columnKey); if (!isset($this->columns[$columnHash])) { return false; } $rowHash = ValueHasher::hash($rowKey); if (!isset($this->rows[$rowHash])) { return false; } return true; }
[ "public", "function", "hasCell", "(", "$", "columnKey", ",", "$", "rowKey", ")", ":", "bool", "{", "$", "this", "->", "validateColumnKey", "(", "__METHOD__", ",", "$", "columnKey", ")", ";", "$", "this", "->", "validateRowKey", "(", "__METHOD__", ",", "$", "rowKey", ")", ";", "$", "this", "->", "loadColumns", "(", ")", ";", "$", "this", "->", "loadRows", "(", ")", ";", "$", "columnHash", "=", "ValueHasher", "::", "hash", "(", "$", "columnKey", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "columns", "[", "$", "columnHash", "]", ")", ")", "{", "return", "false", ";", "}", "$", "rowHash", "=", "ValueHasher", "::", "hash", "(", "$", "rowKey", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "rows", "[", "$", "rowHash", "]", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Returns whether their is a cell value at the supplied row and column. @param mixed $columnKey @param mixed $rowKey @return bool @throws TypeMismatchException
[ "Returns", "whether", "their", "is", "a", "cell", "value", "at", "the", "supplied", "row", "and", "column", "." ]
23f122182f60df5ec847047a81a39c8aab019ff1
https://github.com/dms-org/common.structure/blob/23f122182f60df5ec847047a81a39c8aab019ff1/src/Table/TableData.php#L319-L338
25,309
dms-org/common.structure
src/Table/TableData.php
TableData.getCell
public function getCell($columnKey, $rowKey) { $column = $this->getColumn($columnKey); $row = $this->getRow($rowKey); return $row[$column]; }
php
public function getCell($columnKey, $rowKey) { $column = $this->getColumn($columnKey); $row = $this->getRow($rowKey); return $row[$column]; }
[ "public", "function", "getCell", "(", "$", "columnKey", ",", "$", "rowKey", ")", "{", "$", "column", "=", "$", "this", "->", "getColumn", "(", "$", "columnKey", ")", ";", "$", "row", "=", "$", "this", "->", "getRow", "(", "$", "rowKey", ")", ";", "return", "$", "row", "[", "$", "column", "]", ";", "}" ]
Gets the value of the cell or NULL if the cell does not exist. @param mixed $columnKey @param mixed $rowKey @return mixed @throws TypeMismatchException
[ "Gets", "the", "value", "of", "the", "cell", "or", "NULL", "if", "the", "cell", "does", "not", "exist", "." ]
23f122182f60df5ec847047a81a39c8aab019ff1
https://github.com/dms-org/common.structure/blob/23f122182f60df5ec847047a81a39c8aab019ff1/src/Table/TableData.php#L349-L355
25,310
Dhii/regex-abstract
src/GetAllMatchesRegexCapablePcreTrait.php
GetAllMatchesRegexCapablePcreTrait._getAllMatchesRegex
protected function _getAllMatchesRegex($pattern, $subject) { $matches = []; $pattern = $this->_normalizeString($pattern); $subject = $this->_normalizeString($subject); try { $result = @preg_match_all($pattern, $subject, $matches); } catch (RootException $e) { // This will happen if a custom error handler is set and throws exceptions for regex errors throw $this->_createRuntimeException($this->__($e->getMessage()), null, $e); } if ($result === false) { $errorCode = preg_last_error(); throw $this->_createRuntimeException($this->__('RegEx error code "%1$s"', [$errorCode])); } return $matches; }
php
protected function _getAllMatchesRegex($pattern, $subject) { $matches = []; $pattern = $this->_normalizeString($pattern); $subject = $this->_normalizeString($subject); try { $result = @preg_match_all($pattern, $subject, $matches); } catch (RootException $e) { // This will happen if a custom error handler is set and throws exceptions for regex errors throw $this->_createRuntimeException($this->__($e->getMessage()), null, $e); } if ($result === false) { $errorCode = preg_last_error(); throw $this->_createRuntimeException($this->__('RegEx error code "%1$s"', [$errorCode])); } return $matches; }
[ "protected", "function", "_getAllMatchesRegex", "(", "$", "pattern", ",", "$", "subject", ")", "{", "$", "matches", "=", "[", "]", ";", "$", "pattern", "=", "$", "this", "->", "_normalizeString", "(", "$", "pattern", ")", ";", "$", "subject", "=", "$", "this", "->", "_normalizeString", "(", "$", "subject", ")", ";", "try", "{", "$", "result", "=", "@", "preg_match_all", "(", "$", "pattern", ",", "$", "subject", ",", "$", "matches", ")", ";", "}", "catch", "(", "RootException", "$", "e", ")", "{", "// This will happen if a custom error handler is set and throws exceptions for regex errors", "throw", "$", "this", "->", "_createRuntimeException", "(", "$", "this", "->", "__", "(", "$", "e", "->", "getMessage", "(", ")", ")", ",", "null", ",", "$", "e", ")", ";", "}", "if", "(", "$", "result", "===", "false", ")", "{", "$", "errorCode", "=", "preg_last_error", "(", ")", ";", "throw", "$", "this", "->", "_createRuntimeException", "(", "$", "this", "->", "__", "(", "'RegEx error code \"%1$s\"'", ",", "[", "$", "errorCode", "]", ")", ")", ";", "}", "return", "$", "matches", ";", "}" ]
Retrieves all matches that correspond to a RegEx pattern from a string. @since [*next-version*] @see preg_match_all() @param string|Stringable $pattern The RegEx pattern to use for matching. @param string|Stringable $subject The subject that will be searched for matches. @throw InvalidArgumentException If the pattern or the subject are of the wrong type. @throw RuntimeException If problem matching. @return array The array of matches. Format is same as the matches produced by `preg_match_all()`.
[ "Retrieves", "all", "matches", "that", "correspond", "to", "a", "RegEx", "pattern", "from", "a", "string", "." ]
0751f9c91a6f86d5f901b6b7f3613dc80bb69a8a
https://github.com/Dhii/regex-abstract/blob/0751f9c91a6f86d5f901b6b7f3613dc80bb69a8a/src/GetAllMatchesRegexCapablePcreTrait.php#L35-L54
25,311
bkstg/schedule-bundle
Repository/EventRepository.php
EventRepository.searchEvents
public function searchEvents( Production $production, \DateTime $from, \DateTime $to, bool $active = true ) { $qb = $this->createQueryBuilder('e'); return $qb ->join('e.groups', 'g') // Add conditions. ->andWhere($qb->expr()->eq('g', ':group')) ->andWhere($qb->expr()->between('e.start', ':from', ':to')) ->andWhere($qb->expr()->eq('e.active', ':active')) // Add parameters. ->setParameter('group', $production) ->setParameter('from', $from) ->setParameter('to', $to) ->setParameter('active', $active) // Get results. ->getQuery() ->getResult(); }
php
public function searchEvents( Production $production, \DateTime $from, \DateTime $to, bool $active = true ) { $qb = $this->createQueryBuilder('e'); return $qb ->join('e.groups', 'g') // Add conditions. ->andWhere($qb->expr()->eq('g', ':group')) ->andWhere($qb->expr()->between('e.start', ':from', ':to')) ->andWhere($qb->expr()->eq('e.active', ':active')) // Add parameters. ->setParameter('group', $production) ->setParameter('from', $from) ->setParameter('to', $to) ->setParameter('active', $active) // Get results. ->getQuery() ->getResult(); }
[ "public", "function", "searchEvents", "(", "Production", "$", "production", ",", "\\", "DateTime", "$", "from", ",", "\\", "DateTime", "$", "to", ",", "bool", "$", "active", "=", "true", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'e'", ")", ";", "return", "$", "qb", "->", "join", "(", "'e.groups'", ",", "'g'", ")", "// Add conditions.", "->", "andWhere", "(", "$", "qb", "->", "expr", "(", ")", "->", "eq", "(", "'g'", ",", "':group'", ")", ")", "->", "andWhere", "(", "$", "qb", "->", "expr", "(", ")", "->", "between", "(", "'e.start'", ",", "':from'", ",", "':to'", ")", ")", "->", "andWhere", "(", "$", "qb", "->", "expr", "(", ")", "->", "eq", "(", "'e.active'", ",", "':active'", ")", ")", "// Add parameters.", "->", "setParameter", "(", "'group'", ",", "$", "production", ")", "->", "setParameter", "(", "'from'", ",", "$", "from", ")", "->", "setParameter", "(", "'to'", ",", "$", "to", ")", "->", "setParameter", "(", "'active'", ",", "$", "active", ")", "// Get results.", "->", "getQuery", "(", ")", "->", "getResult", "(", ")", ";", "}" ]
Search for events within a production. @param Production $production The production to search in. @param \DateTime $from The time to start searching from. @param \DateTime $to The time to end searching from. @param bool $active The active state of the events. @return Event[]
[ "Search", "for", "events", "within", "a", "production", "." ]
e64ac897aa7b28bc48319470d65de13cd4788afe
https://github.com/bkstg/schedule-bundle/blob/e64ac897aa7b28bc48319470d65de13cd4788afe/Repository/EventRepository.php#L32-L57
25,312
bkstg/schedule-bundle
Repository/EventRepository.php
EventRepository.searchEventsByUser
public function searchEventsByUser( UserInterface $user, \DateTime $from, \DateTime $to, bool $active = true ) { $qb = $this->createQueryBuilder('e'); return $qb ->join('e.invitations', 'i') // Add conditions. ->andWhere($qb->expr()->between('e.start', ':from', ':to')) ->andWhere($qb->expr()->eq('i.invitee', ':invitee')) ->andWhere($qb->expr()->eq('e.active', ':active')) ->andWhere($qb->expr()->orX( $qb->expr()->isNull('i.response'), $qb->expr()->neq('i.response', ':decline') )) // Add parameters. ->setParameter('from', $from) ->setParameter('to', $to) ->setParameter('invitee', $user->getUsername()) ->setParameter('decline', Invitation::RESPONSE_DECLINE) ->setParameter('active', $active) // Get results. ->getQuery() ->getResult(); }
php
public function searchEventsByUser( UserInterface $user, \DateTime $from, \DateTime $to, bool $active = true ) { $qb = $this->createQueryBuilder('e'); return $qb ->join('e.invitations', 'i') // Add conditions. ->andWhere($qb->expr()->between('e.start', ':from', ':to')) ->andWhere($qb->expr()->eq('i.invitee', ':invitee')) ->andWhere($qb->expr()->eq('e.active', ':active')) ->andWhere($qb->expr()->orX( $qb->expr()->isNull('i.response'), $qb->expr()->neq('i.response', ':decline') )) // Add parameters. ->setParameter('from', $from) ->setParameter('to', $to) ->setParameter('invitee', $user->getUsername()) ->setParameter('decline', Invitation::RESPONSE_DECLINE) ->setParameter('active', $active) // Get results. ->getQuery() ->getResult(); }
[ "public", "function", "searchEventsByUser", "(", "UserInterface", "$", "user", ",", "\\", "DateTime", "$", "from", ",", "\\", "DateTime", "$", "to", ",", "bool", "$", "active", "=", "true", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'e'", ")", ";", "return", "$", "qb", "->", "join", "(", "'e.invitations'", ",", "'i'", ")", "// Add conditions.", "->", "andWhere", "(", "$", "qb", "->", "expr", "(", ")", "->", "between", "(", "'e.start'", ",", "':from'", ",", "':to'", ")", ")", "->", "andWhere", "(", "$", "qb", "->", "expr", "(", ")", "->", "eq", "(", "'i.invitee'", ",", "':invitee'", ")", ")", "->", "andWhere", "(", "$", "qb", "->", "expr", "(", ")", "->", "eq", "(", "'e.active'", ",", "':active'", ")", ")", "->", "andWhere", "(", "$", "qb", "->", "expr", "(", ")", "->", "orX", "(", "$", "qb", "->", "expr", "(", ")", "->", "isNull", "(", "'i.response'", ")", ",", "$", "qb", "->", "expr", "(", ")", "->", "neq", "(", "'i.response'", ",", "':decline'", ")", ")", ")", "// Add parameters.", "->", "setParameter", "(", "'from'", ",", "$", "from", ")", "->", "setParameter", "(", "'to'", ",", "$", "to", ")", "->", "setParameter", "(", "'invitee'", ",", "$", "user", "->", "getUsername", "(", ")", ")", "->", "setParameter", "(", "'decline'", ",", "Invitation", "::", "RESPONSE_DECLINE", ")", "->", "setParameter", "(", "'active'", ",", "$", "active", ")", "// Get results.", "->", "getQuery", "(", ")", "->", "getResult", "(", ")", ";", "}" ]
Search for events for a user. @param UserInterface $user The production to search in. @param \DateTime $from The time to start searching from. @param \DateTime $to The time to end searching from. @param bool $active The active state of the events. @return Event[]
[ "Search", "for", "events", "for", "a", "user", "." ]
e64ac897aa7b28bc48319470d65de13cd4788afe
https://github.com/bkstg/schedule-bundle/blob/e64ac897aa7b28bc48319470d65de13cd4788afe/Repository/EventRepository.php#L69-L99
25,313
bkstg/schedule-bundle
Repository/EventRepository.php
EventRepository.findArchivedEventsQuery
public function findArchivedEventsQuery(Production $production) { $qb = $this->createQueryBuilder('e'); return $qb // Add joins. ->join('e.groups', 'g') // Add conditions. ->andWhere($qb->expr()->eq('g', ':production')) ->andWhere($qb->expr()->eq('e.active', ':active')) ->andWhere($qb->expr()->isNull('e.schedule')) // Add parameters. ->setParameter('production', $production) ->setParameter('active', false) // Add ordering. ->addOrderBy('e.updated', 'DESC') // Get query. ->getQuery(); }
php
public function findArchivedEventsQuery(Production $production) { $qb = $this->createQueryBuilder('e'); return $qb // Add joins. ->join('e.groups', 'g') // Add conditions. ->andWhere($qb->expr()->eq('g', ':production')) ->andWhere($qb->expr()->eq('e.active', ':active')) ->andWhere($qb->expr()->isNull('e.schedule')) // Add parameters. ->setParameter('production', $production) ->setParameter('active', false) // Add ordering. ->addOrderBy('e.updated', 'DESC') // Get query. ->getQuery(); }
[ "public", "function", "findArchivedEventsQuery", "(", "Production", "$", "production", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'e'", ")", ";", "return", "$", "qb", "// Add joins.", "->", "join", "(", "'e.groups'", ",", "'g'", ")", "// Add conditions.", "->", "andWhere", "(", "$", "qb", "->", "expr", "(", ")", "->", "eq", "(", "'g'", ",", "':production'", ")", ")", "->", "andWhere", "(", "$", "qb", "->", "expr", "(", ")", "->", "eq", "(", "'e.active'", ",", "':active'", ")", ")", "->", "andWhere", "(", "$", "qb", "->", "expr", "(", ")", "->", "isNull", "(", "'e.schedule'", ")", ")", "// Add parameters.", "->", "setParameter", "(", "'production'", ",", "$", "production", ")", "->", "setParameter", "(", "'active'", ",", "false", ")", "// Add ordering.", "->", "addOrderBy", "(", "'e.updated'", ",", "'DESC'", ")", "// Get query.", "->", "getQuery", "(", ")", ";", "}" ]
Helper function to search for events that are not active. @param Production $production The production to search in. @return Event[]
[ "Helper", "function", "to", "search", "for", "events", "that", "are", "not", "active", "." ]
e64ac897aa7b28bc48319470d65de13cd4788afe
https://github.com/bkstg/schedule-bundle/blob/e64ac897aa7b28bc48319470d65de13cd4788afe/Repository/EventRepository.php#L108-L130
25,314
bseddon/XPath20
SequenceType.php
SequenceType.getValueType
public function getValueType() { if ( $this->Cardinality == XmlTypeCardinality::ZeroOrMore || $this->Cardinality == XmlTypeCardinality::OneOrMore ) return "\lyquidity\XPath2\XPath2NodeIterator"; if ( $this->IsNode ) return "\lyquidity\xml\xpath\XPathNavigator"; if ($this->Cardinality == XmlTypeCardinality::One) return $this->ItemType; return "object"; }
php
public function getValueType() { if ( $this->Cardinality == XmlTypeCardinality::ZeroOrMore || $this->Cardinality == XmlTypeCardinality::OneOrMore ) return "\lyquidity\XPath2\XPath2NodeIterator"; if ( $this->IsNode ) return "\lyquidity\xml\xpath\XPathNavigator"; if ($this->Cardinality == XmlTypeCardinality::One) return $this->ItemType; return "object"; }
[ "public", "function", "getValueType", "(", ")", "{", "if", "(", "$", "this", "->", "Cardinality", "==", "XmlTypeCardinality", "::", "ZeroOrMore", "||", "$", "this", "->", "Cardinality", "==", "XmlTypeCardinality", "::", "OneOrMore", ")", "return", "\"\\lyquidity\\XPath2\\XPath2NodeIterator\"", ";", "if", "(", "$", "this", "->", "IsNode", ")", "return", "\"\\lyquidity\\xml\\xpath\\XPathNavigator\"", ";", "if", "(", "$", "this", "->", "Cardinality", "==", "XmlTypeCardinality", "::", "One", ")", "return", "$", "this", "->", "ItemType", ";", "return", "\"object\"", ";", "}" ]
Get the type of the value @var Type $ValueType
[ "Get", "the", "type", "of", "the", "value" ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/SequenceType.php#L291-L304
25,315
bseddon/XPath20
SequenceType.php
SequenceType.getAtomizedValueType
public function getAtomizedValueType() { if ( $this->IsNode ) { switch ( $this->TypeCode ) { case XmlTypeCode::Text: case XmlTypeCode::ProcessingInstruction: case XmlTypeCode::Comment: case XmlTypeCode::UntypedAtomic: return Types::$UntypedAtomicType; default: if ( ! is_null( $this->SchemaType ) ) return $this->SchemaType->Datatype->ValueType; else if ( ! is_null( $this->SchemaElement ) ) { if ( ! is_null( $this->SchemaElement->ElementSchemaType ) && ! is_null( $this->SchemaElement->ElementSchemaType->Datatype ) ) return $this->SchemaElement->ElementSchemaType->Datatype->ValueType; } else if ( ! is_null( $this->SchemaAttribute ) ) { if ( ! is_null( $this->SchemaAttribute->AttributeSchemaType ) && ! is_null( $this->SchemaAttribute->AttributeSchemaType->Datatype ) ) return $this->SchemaAttribute->AttributeSchemaType->Datatype->ValueType; } return Types::$UntypedAtomicType; } } else return $this->ItemType; }
php
public function getAtomizedValueType() { if ( $this->IsNode ) { switch ( $this->TypeCode ) { case XmlTypeCode::Text: case XmlTypeCode::ProcessingInstruction: case XmlTypeCode::Comment: case XmlTypeCode::UntypedAtomic: return Types::$UntypedAtomicType; default: if ( ! is_null( $this->SchemaType ) ) return $this->SchemaType->Datatype->ValueType; else if ( ! is_null( $this->SchemaElement ) ) { if ( ! is_null( $this->SchemaElement->ElementSchemaType ) && ! is_null( $this->SchemaElement->ElementSchemaType->Datatype ) ) return $this->SchemaElement->ElementSchemaType->Datatype->ValueType; } else if ( ! is_null( $this->SchemaAttribute ) ) { if ( ! is_null( $this->SchemaAttribute->AttributeSchemaType ) && ! is_null( $this->SchemaAttribute->AttributeSchemaType->Datatype ) ) return $this->SchemaAttribute->AttributeSchemaType->Datatype->ValueType; } return Types::$UntypedAtomicType; } } else return $this->ItemType; }
[ "public", "function", "getAtomizedValueType", "(", ")", "{", "if", "(", "$", "this", "->", "IsNode", ")", "{", "switch", "(", "$", "this", "->", "TypeCode", ")", "{", "case", "XmlTypeCode", "::", "Text", ":", "case", "XmlTypeCode", "::", "ProcessingInstruction", ":", "case", "XmlTypeCode", "::", "Comment", ":", "case", "XmlTypeCode", "::", "UntypedAtomic", ":", "return", "Types", "::", "$", "UntypedAtomicType", ";", "default", ":", "if", "(", "!", "is_null", "(", "$", "this", "->", "SchemaType", ")", ")", "return", "$", "this", "->", "SchemaType", "->", "Datatype", "->", "ValueType", ";", "else", "if", "(", "!", "is_null", "(", "$", "this", "->", "SchemaElement", ")", ")", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "SchemaElement", "->", "ElementSchemaType", ")", "&&", "!", "is_null", "(", "$", "this", "->", "SchemaElement", "->", "ElementSchemaType", "->", "Datatype", ")", ")", "return", "$", "this", "->", "SchemaElement", "->", "ElementSchemaType", "->", "Datatype", "->", "ValueType", ";", "}", "else", "if", "(", "!", "is_null", "(", "$", "this", "->", "SchemaAttribute", ")", ")", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "SchemaAttribute", "->", "AttributeSchemaType", ")", "&&", "!", "is_null", "(", "$", "this", "->", "SchemaAttribute", "->", "AttributeSchemaType", "->", "Datatype", ")", ")", "return", "$", "this", "->", "SchemaAttribute", "->", "AttributeSchemaType", "->", "Datatype", "->", "ValueType", ";", "}", "return", "Types", "::", "$", "UntypedAtomicType", ";", "}", "}", "else", "return", "$", "this", "->", "ItemType", ";", "}" ]
Get the type of the atomized value @return Type
[ "Get", "the", "type", "of", "the", "atomized", "value" ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/SequenceType.php#L310-L341
25,316
bseddon/XPath20
SequenceType.php
SequenceType.getIsNumeric
public function getIsNumeric() { switch ( $this->TypeCode ) { case XmlTypeCode::Decimal: case XmlTypeCode::Float: case XmlTypeCode::Double: case XmlTypeCode::Integer: case XmlTypeCode::NonPositiveInteger: case XmlTypeCode::NegativeInteger: case XmlTypeCode::Long: case XmlTypeCode::Int: case XmlTypeCode::Short: case XmlTypeCode::Byte: case XmlTypeCode::NonNegativeInteger: case XmlTypeCode::UnsignedLong: case XmlTypeCode::UnsignedInt: case XmlTypeCode::UnsignedShort: case XmlTypeCode::UnsignedByte: case XmlTypeCode::PositiveInteger: return true; } return false; }
php
public function getIsNumeric() { switch ( $this->TypeCode ) { case XmlTypeCode::Decimal: case XmlTypeCode::Float: case XmlTypeCode::Double: case XmlTypeCode::Integer: case XmlTypeCode::NonPositiveInteger: case XmlTypeCode::NegativeInteger: case XmlTypeCode::Long: case XmlTypeCode::Int: case XmlTypeCode::Short: case XmlTypeCode::Byte: case XmlTypeCode::NonNegativeInteger: case XmlTypeCode::UnsignedLong: case XmlTypeCode::UnsignedInt: case XmlTypeCode::UnsignedShort: case XmlTypeCode::UnsignedByte: case XmlTypeCode::PositiveInteger: return true; } return false; }
[ "public", "function", "getIsNumeric", "(", ")", "{", "switch", "(", "$", "this", "->", "TypeCode", ")", "{", "case", "XmlTypeCode", "::", "Decimal", ":", "case", "XmlTypeCode", "::", "Float", ":", "case", "XmlTypeCode", "::", "Double", ":", "case", "XmlTypeCode", "::", "Integer", ":", "case", "XmlTypeCode", "::", "NonPositiveInteger", ":", "case", "XmlTypeCode", "::", "NegativeInteger", ":", "case", "XmlTypeCode", "::", "Long", ":", "case", "XmlTypeCode", "::", "Int", ":", "case", "XmlTypeCode", "::", "Short", ":", "case", "XmlTypeCode", "::", "Byte", ":", "case", "XmlTypeCode", "::", "NonNegativeInteger", ":", "case", "XmlTypeCode", "::", "UnsignedLong", ":", "case", "XmlTypeCode", "::", "UnsignedInt", ":", "case", "XmlTypeCode", "::", "UnsignedShort", ":", "case", "XmlTypeCode", "::", "UnsignedByte", ":", "case", "XmlTypeCode", "::", "PositiveInteger", ":", "return", "true", ";", "}", "return", "false", ";", "}" ]
Returns true if the value is numeric @return bool
[ "Returns", "true", "if", "the", "value", "is", "numeric" ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/SequenceType.php#L347-L370
25,317
vainproject/vain-user
src/User/Observers/UserObserver.php
UserObserver.deleting
public function deleting($model) { foreach ($this->relations as $relation) { if ($model->{$relation}()->count() > 0) { // Returning false from an Eloquent event listener will cancel the operation. return false; } } }
php
public function deleting($model) { foreach ($this->relations as $relation) { if ($model->{$relation}()->count() > 0) { // Returning false from an Eloquent event listener will cancel the operation. return false; } } }
[ "public", "function", "deleting", "(", "$", "model", ")", "{", "foreach", "(", "$", "this", "->", "relations", "as", "$", "relation", ")", "{", "if", "(", "$", "model", "->", "{", "$", "relation", "}", "(", ")", "->", "count", "(", ")", ">", "0", ")", "{", "// Returning false from an Eloquent event listener will cancel the operation.", "return", "false", ";", "}", "}", "}" ]
Post delete check if a user has any relevant relations, if so we cancel the deletion and ask the user to manually remove all relations for now. @param $model @return bool
[ "Post", "delete", "check", "if", "a", "user", "has", "any", "relevant", "relations", "if", "so", "we", "cancel", "the", "deletion", "and", "ask", "the", "user", "to", "manually", "remove", "all", "relations", "for", "now", "." ]
1c059faa61ebf289fcaea39a90b4523cfc9d6efc
https://github.com/vainproject/vain-user/blob/1c059faa61ebf289fcaea39a90b4523cfc9d6efc/src/User/Observers/UserObserver.php#L22-L30
25,318
Wedeto/Util
src/ErrorInterceptor.php
ErrorInterceptor.execute
public function execute() { $registered = false; if (self::$interceptor_stack === null) { $registered = true; self::registerErrorHandler(); } array_push(self::$interceptor_stack, $this); $response = null; try { $response = call_user_func_array($this->func, func_get_args()); } finally { array_pop(self::$interceptor_stack); if ($registered) self::unregisterErrorHandler(); } return $response; }
php
public function execute() { $registered = false; if (self::$interceptor_stack === null) { $registered = true; self::registerErrorHandler(); } array_push(self::$interceptor_stack, $this); $response = null; try { $response = call_user_func_array($this->func, func_get_args()); } finally { array_pop(self::$interceptor_stack); if ($registered) self::unregisterErrorHandler(); } return $response; }
[ "public", "function", "execute", "(", ")", "{", "$", "registered", "=", "false", ";", "if", "(", "self", "::", "$", "interceptor_stack", "===", "null", ")", "{", "$", "registered", "=", "true", ";", "self", "::", "registerErrorHandler", "(", ")", ";", "}", "array_push", "(", "self", "::", "$", "interceptor_stack", ",", "$", "this", ")", ";", "$", "response", "=", "null", ";", "try", "{", "$", "response", "=", "call_user_func_array", "(", "$", "this", "->", "func", ",", "func_get_args", "(", ")", ")", ";", "}", "finally", "{", "array_pop", "(", "self", "::", "$", "interceptor_stack", ")", ";", "if", "(", "$", "registered", ")", "self", "::", "unregisterErrorHandler", "(", ")", ";", "}", "return", "$", "response", ";", "}" ]
Execute the configured callback @params Any parameters to pass to the callback @return mixed The return value of the callback
[ "Execute", "the", "configured", "callback" ]
0e080251bbaa8e7d91ae8d02eb79c029c976744a
https://github.com/Wedeto/Util/blob/0e080251bbaa8e7d91ae8d02eb79c029c976744a/src/ErrorInterceptor.php#L82-L105
25,319
Wedeto/Util
src/ErrorInterceptor.php
ErrorInterceptor.intercept
protected function intercept($errno, $errstr, $errfile, $errline, $errcontext) { foreach ($this->expected as $warning) { if ($errno & $warning[0] && strpos($errstr, $warning[1]) !== false) { $this->intercepted[] = new \ErrorException($errstr, 0, $errno, $errfile, $errline); return true; } } return false; }
php
protected function intercept($errno, $errstr, $errfile, $errline, $errcontext) { foreach ($this->expected as $warning) { if ($errno & $warning[0] && strpos($errstr, $warning[1]) !== false) { $this->intercepted[] = new \ErrorException($errstr, 0, $errno, $errfile, $errline); return true; } } return false; }
[ "protected", "function", "intercept", "(", "$", "errno", ",", "$", "errstr", ",", "$", "errfile", ",", "$", "errline", ",", "$", "errcontext", ")", "{", "foreach", "(", "$", "this", "->", "expected", "as", "$", "warning", ")", "{", "if", "(", "$", "errno", "&", "$", "warning", "[", "0", "]", "&&", "strpos", "(", "$", "errstr", ",", "$", "warning", "[", "1", "]", ")", "!==", "false", ")", "{", "$", "this", "->", "intercepted", "[", "]", "=", "new", "\\", "ErrorException", "(", "$", "errstr", ",", "0", ",", "$", "errno", ",", "$", "errfile", ",", "$", "errline", ")", ";", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check if the produced error should be intercepted by the interceptor, based on the defined expected errors. @param int $errno Error type @param string $errstr The error string @param string $errfile The file the error occured in @param int $errline The line the error occured on @param array $errcontext Local variables @return bool True if the message was intercepted, false if not
[ "Check", "if", "the", "produced", "error", "should", "be", "intercepted", "by", "the", "interceptor", "based", "on", "the", "defined", "expected", "errors", "." ]
0e080251bbaa8e7d91ae8d02eb79c029c976744a
https://github.com/Wedeto/Util/blob/0e080251bbaa8e7d91ae8d02eb79c029c976744a/src/ErrorInterceptor.php#L126-L137
25,320
Wedeto/Util
src/ErrorInterceptor.php
ErrorInterceptor.errorHandler
public static function errorHandler($errno, $errstr, $errfile, $errline, $errcontext) { if (count(self::$interceptor_stack) > 0) { $interceptor = end(self::$interceptor_stack); if ($interceptor->intercept($errno, $errstr, $errfile, $errline, $errcontext)) { return; } } throw new ErrorException($errstr, 0, $errno, $errfile, $errline); }
php
public static function errorHandler($errno, $errstr, $errfile, $errline, $errcontext) { if (count(self::$interceptor_stack) > 0) { $interceptor = end(self::$interceptor_stack); if ($interceptor->intercept($errno, $errstr, $errfile, $errline, $errcontext)) { return; } } throw new ErrorException($errstr, 0, $errno, $errfile, $errline); }
[ "public", "static", "function", "errorHandler", "(", "$", "errno", ",", "$", "errstr", ",", "$", "errfile", ",", "$", "errline", ",", "$", "errcontext", ")", "{", "if", "(", "count", "(", "self", "::", "$", "interceptor_stack", ")", ">", "0", ")", "{", "$", "interceptor", "=", "end", "(", "self", "::", "$", "interceptor_stack", ")", ";", "if", "(", "$", "interceptor", "->", "intercept", "(", "$", "errno", ",", "$", "errstr", ",", "$", "errfile", ",", "$", "errline", ",", "$", "errcontext", ")", ")", "{", "return", ";", "}", "}", "throw", "new", "ErrorException", "(", "$", "errstr", ",", "0", ",", "$", "errno", ",", "$", "errfile", ",", "$", "errline", ")", ";", "}" ]
Catch all PHP errors, notices and throw them as an exception instead. If an interceptor was registered, the message is passed to the interceptor instead. @param int $errno Error number @param string $errstr Error description @param string $errfile The file where the error occured @param int $errline The line where the error occured @param mixed $errcontext Erro context
[ "Catch", "all", "PHP", "errors", "notices", "and", "throw", "them", "as", "an", "exception", "instead", ".", "If", "an", "interceptor", "was", "registered", "the", "message", "is", "passed", "to", "the", "interceptor", "instead", "." ]
0e080251bbaa8e7d91ae8d02eb79c029c976744a
https://github.com/Wedeto/Util/blob/0e080251bbaa8e7d91ae8d02eb79c029c976744a/src/ErrorInterceptor.php#L154-L166
25,321
linpax/microphp-framework
src/auth/drivers/FileRbac.php
FileRbac.assign
public function assign($userId, $name) { if ($this->searchRoleRecursive($this->roles, $name)) { $exists = $this->db->exists('rbac_user', ['user' => $userId, 'role' => $name]); if (!$exists) { return $this->db->insert('rbac_user', ['role' => $name, 'user' => $userId]); } } return false; }
php
public function assign($userId, $name) { if ($this->searchRoleRecursive($this->roles, $name)) { $exists = $this->db->exists('rbac_user', ['user' => $userId, 'role' => $name]); if (!$exists) { return $this->db->insert('rbac_user', ['role' => $name, 'user' => $userId]); } } return false; }
[ "public", "function", "assign", "(", "$", "userId", ",", "$", "name", ")", "{", "if", "(", "$", "this", "->", "searchRoleRecursive", "(", "$", "this", "->", "roles", ",", "$", "name", ")", ")", "{", "$", "exists", "=", "$", "this", "->", "db", "->", "exists", "(", "'rbac_user'", ",", "[", "'user'", "=>", "$", "userId", ",", "'role'", "=>", "$", "name", "]", ")", ";", "if", "(", "!", "$", "exists", ")", "{", "return", "$", "this", "->", "db", "->", "insert", "(", "'rbac_user'", ",", "[", "'role'", "=>", "$", "name", ",", "'user'", "=>", "$", "userId", "]", ")", ";", "}", "}", "return", "false", ";", "}" ]
Assign RBAC element into user @access public @param integer $userId user id @param string $name element name @return bool
[ "Assign", "RBAC", "element", "into", "user" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/auth/drivers/FileRbac.php#L55-L65
25,322
OxfordInfoLabs/kinikit-core
src/Util/Configuration/ConfigFile.php
ConfigFile.getParameter
public function getParameter($key) { if (array_key_exists ( $key, $this->parameters )) return $this->parameters [$key]; else return null; }
php
public function getParameter($key) { if (array_key_exists ( $key, $this->parameters )) return $this->parameters [$key]; else return null; }
[ "public", "function", "getParameter", "(", "$", "key", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "parameters", ")", ")", "return", "$", "this", "->", "parameters", "[", "$", "key", "]", ";", "else", "return", "null", ";", "}" ]
Get the parameter matching the passed key or null if non existent @param string $key
[ "Get", "the", "parameter", "matching", "the", "passed", "key", "or", "null", "if", "non", "existent" ]
edc1b2e6ffabd595c4c7d322279b3dd1e59ef359
https://github.com/OxfordInfoLabs/kinikit-core/blob/edc1b2e6ffabd595c4c7d322279b3dd1e59ef359/src/Util/Configuration/ConfigFile.php#L37-L42
25,323
OxfordInfoLabs/kinikit-core
src/Util/Configuration/ConfigFile.php
ConfigFile.getConfigFileText
public function getConfigFileText() { $configFileText = ""; foreach ( $this->parameters as $key => $value ) { $configFileText .= $key . "=" . $value . "\n"; } return $configFileText; }
php
public function getConfigFileText() { $configFileText = ""; foreach ( $this->parameters as $key => $value ) { $configFileText .= $key . "=" . $value . "\n"; } return $configFileText; }
[ "public", "function", "getConfigFileText", "(", ")", "{", "$", "configFileText", "=", "\"\"", ";", "foreach", "(", "$", "this", "->", "parameters", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "configFileText", ".=", "$", "key", ".", "\"=\"", ".", "$", "value", ".", "\"\\n\"", ";", "}", "return", "$", "configFileText", ";", "}" ]
Return the actual text which would be written out by the save method. This is particularly useful in situations like the PropertiesResource where the output needs to be injected into a resource. @return string
[ "Return", "the", "actual", "text", "which", "would", "be", "written", "out", "by", "the", "save", "method", ".", "This", "is", "particularly", "useful", "in", "situations", "like", "the", "PropertiesResource", "where", "the", "output", "needs", "to", "be", "injected", "into", "a", "resource", "." ]
edc1b2e6ffabd595c4c7d322279b3dd1e59ef359
https://github.com/OxfordInfoLabs/kinikit-core/blob/edc1b2e6ffabd595c4c7d322279b3dd1e59ef359/src/Util/Configuration/ConfigFile.php#L88-L94
25,324
OxfordInfoLabs/kinikit-core
src/Util/Configuration/ConfigFile.php
ConfigFile.save
public function save($filePath = null) { // Determine the correct file path. $filePath = ($filePath == null) ? $this->configFilePath : $filePath; // Store the file file_put_contents ( $filePath, $this->getConfigFileText () ); }
php
public function save($filePath = null) { // Determine the correct file path. $filePath = ($filePath == null) ? $this->configFilePath : $filePath; // Store the file file_put_contents ( $filePath, $this->getConfigFileText () ); }
[ "public", "function", "save", "(", "$", "filePath", "=", "null", ")", "{", "// Determine the correct file path.", "$", "filePath", "=", "(", "$", "filePath", "==", "null", ")", "?", "$", "this", "->", "configFilePath", ":", "$", "filePath", ";", "// Store the file", "file_put_contents", "(", "$", "filePath", ",", "$", "this", "->", "getConfigFileText", "(", ")", ")", ";", "}" ]
Save the config file back out. If null supplied for filepath, the constructed configFilePath is used
[ "Save", "the", "config", "file", "back", "out", ".", "If", "null", "supplied", "for", "filepath", "the", "constructed", "configFilePath", "is", "used" ]
edc1b2e6ffabd595c4c7d322279b3dd1e59ef359
https://github.com/OxfordInfoLabs/kinikit-core/blob/edc1b2e6ffabd595c4c7d322279b3dd1e59ef359/src/Util/Configuration/ConfigFile.php#L100-L107
25,325
OxfordInfoLabs/kinikit-core
src/Util/Configuration/ConfigFile.php
ConfigFile.parseFile
private function parseFile($configFilePath) { $configFileText = file_get_contents ( $configFilePath ); // Now split each line on carriage return $lines = explode ( "\n", $configFileText ); // Now loop through each line, attempting a split by equals sign to get key value pairs out. foreach ( $lines as $line ) { // Firstly split lines on # to ensure that comments are ignored $splitComment = explode ( "#", $line ); $propertyLine = trim ( $splitComment [0] ); // if the first entry is zero length when trimmed we know the line is a comment so we ignore the whole line // Otherwise continue and use the bit before any potential comment if (strlen ( $propertyLine ) > 0) { // Now split into key, value on = $positionOfFirstEquals = strpos ( $propertyLine, "=" ); // If there are not 2 or more array entries at this point we should complain unless we meet a blank line. if ($positionOfFirstEquals) { $this->parameters [trim ( substr ( $propertyLine, 0, $positionOfFirstEquals ) )] = trim ( substr ( $propertyLine, $positionOfFirstEquals + 1 ) ); } else { throw new Exception ( "Error in config file: Parameter '" . $propertyLine . "' Does not have a value" ); } } } }
php
private function parseFile($configFilePath) { $configFileText = file_get_contents ( $configFilePath ); // Now split each line on carriage return $lines = explode ( "\n", $configFileText ); // Now loop through each line, attempting a split by equals sign to get key value pairs out. foreach ( $lines as $line ) { // Firstly split lines on # to ensure that comments are ignored $splitComment = explode ( "#", $line ); $propertyLine = trim ( $splitComment [0] ); // if the first entry is zero length when trimmed we know the line is a comment so we ignore the whole line // Otherwise continue and use the bit before any potential comment if (strlen ( $propertyLine ) > 0) { // Now split into key, value on = $positionOfFirstEquals = strpos ( $propertyLine, "=" ); // If there are not 2 or more array entries at this point we should complain unless we meet a blank line. if ($positionOfFirstEquals) { $this->parameters [trim ( substr ( $propertyLine, 0, $positionOfFirstEquals ) )] = trim ( substr ( $propertyLine, $positionOfFirstEquals + 1 ) ); } else { throw new Exception ( "Error in config file: Parameter '" . $propertyLine . "' Does not have a value" ); } } } }
[ "private", "function", "parseFile", "(", "$", "configFilePath", ")", "{", "$", "configFileText", "=", "file_get_contents", "(", "$", "configFilePath", ")", ";", "// Now split each line on carriage return", "$", "lines", "=", "explode", "(", "\"\\n\"", ",", "$", "configFileText", ")", ";", "// Now loop through each line, attempting a split by equals sign to get key value pairs out.", "foreach", "(", "$", "lines", "as", "$", "line", ")", "{", "// Firstly split lines on # to ensure that comments are ignored", "$", "splitComment", "=", "explode", "(", "\"#\"", ",", "$", "line", ")", ";", "$", "propertyLine", "=", "trim", "(", "$", "splitComment", "[", "0", "]", ")", ";", "// if the first entry is zero length when trimmed we know the line is a comment so we ignore the whole line", "// Otherwise continue and use the bit before any potential comment", "if", "(", "strlen", "(", "$", "propertyLine", ")", ">", "0", ")", "{", "// Now split into key, value on =", "$", "positionOfFirstEquals", "=", "strpos", "(", "$", "propertyLine", ",", "\"=\"", ")", ";", "// If there are not 2 or more array entries at this point we should complain unless we meet a blank line.", "if", "(", "$", "positionOfFirstEquals", ")", "{", "$", "this", "->", "parameters", "[", "trim", "(", "substr", "(", "$", "propertyLine", ",", "0", ",", "$", "positionOfFirstEquals", ")", ")", "]", "=", "trim", "(", "substr", "(", "$", "propertyLine", ",", "$", "positionOfFirstEquals", "+", "1", ")", ")", ";", "}", "else", "{", "throw", "new", "Exception", "(", "\"Error in config file: Parameter '\"", ".", "$", "propertyLine", ".", "\"' Does not have a value\"", ")", ";", "}", "}", "}", "}" ]
Parse function. Splits the config file into lines and then looks for key value pairs of the form key=value
[ "Parse", "function", ".", "Splits", "the", "config", "file", "into", "lines", "and", "then", "looks", "for", "key", "value", "pairs", "of", "the", "form", "key", "=", "value" ]
edc1b2e6ffabd595c4c7d322279b3dd1e59ef359
https://github.com/OxfordInfoLabs/kinikit-core/blob/edc1b2e6ffabd595c4c7d322279b3dd1e59ef359/src/Util/Configuration/ConfigFile.php#L113-L143
25,326
lasallecms/lasallecms-l5-usermanagement-pkg
src/Helpers/TwoFactorAuthorization/TwoFactorAuthHelper.php
TwoFactorAuthHelper.doTwoFactorAuthLogin
public function doTwoFactorAuthLogin($userId) { // Get the 2FA code $codeToInput = $this->getCodeToInput(); // Update the user's database record wtih the 2FA code & timestamp $this->updateUserRecordWithTwoFactorAuthCode($codeToInput, $userId); // Put together the SMS message $message = config('lasallecmsfrontend.site_name'); $message .= ". Your two factor authorization login code is "; $message .= $codeToInput; $this->shortMessageService->sendSMS($this->getUserPhoneCountryCode($userId), $this->getUserPhoneNumber($userId), $message); }
php
public function doTwoFactorAuthLogin($userId) { // Get the 2FA code $codeToInput = $this->getCodeToInput(); // Update the user's database record wtih the 2FA code & timestamp $this->updateUserRecordWithTwoFactorAuthCode($codeToInput, $userId); // Put together the SMS message $message = config('lasallecmsfrontend.site_name'); $message .= ". Your two factor authorization login code is "; $message .= $codeToInput; $this->shortMessageService->sendSMS($this->getUserPhoneCountryCode($userId), $this->getUserPhoneNumber($userId), $message); }
[ "public", "function", "doTwoFactorAuthLogin", "(", "$", "userId", ")", "{", "// Get the 2FA code", "$", "codeToInput", "=", "$", "this", "->", "getCodeToInput", "(", ")", ";", "// Update the user's database record wtih the 2FA code & timestamp", "$", "this", "->", "updateUserRecordWithTwoFactorAuthCode", "(", "$", "codeToInput", ",", "$", "userId", ")", ";", "// Put together the SMS message", "$", "message", "=", "config", "(", "'lasallecmsfrontend.site_name'", ")", ";", "$", "message", ".=", "\". Your two factor authorization login code is \"", ";", "$", "message", ".=", "$", "codeToInput", ";", "$", "this", "->", "shortMessageService", "->", "sendSMS", "(", "$", "this", "->", "getUserPhoneCountryCode", "(", "$", "userId", ")", ",", "$", "this", "->", "getUserPhoneNumber", "(", "$", "userId", ")", ",", "$", "message", ")", ";", "}" ]
Two Factor Authorization for the front-end LOGIN @param int $userId User ID @return void
[ "Two", "Factor", "Authorization", "for", "the", "front", "-", "end", "LOGIN" ]
b5203d596e18e2566e7fdcd3f13868bb44a94c1d
https://github.com/lasallecms/lasallecms-l5-usermanagement-pkg/blob/b5203d596e18e2566e7fdcd3f13868bb44a94c1d/src/Helpers/TwoFactorAuthorization/TwoFactorAuthHelper.php#L88-L102
25,327
lasallecms/lasallecms-l5-usermanagement-pkg
src/Helpers/TwoFactorAuthorization/TwoFactorAuthHelper.php
TwoFactorAuthHelper.doTwoFactorAuthRegistration
public function doTwoFactorAuthRegistration($data) { // Get the 2FA code $codeToInput = $this->getCodeToInput(); // Set this 2FA code into a session variable, since // this is the only opportunity to so save the ephemerally generated 2FA $this->request->session()->put('codeToInput', $codeToInput); // Put together the SMS message $message = config('lasallecmsfrontend.site_name'); $message .= ". Your two factor authorization login code is "; $message .= $codeToInput; $this->shortMessageService->sendSMS($data['phone_country_code'], $data['phone_number'], $message); }
php
public function doTwoFactorAuthRegistration($data) { // Get the 2FA code $codeToInput = $this->getCodeToInput(); // Set this 2FA code into a session variable, since // this is the only opportunity to so save the ephemerally generated 2FA $this->request->session()->put('codeToInput', $codeToInput); // Put together the SMS message $message = config('lasallecmsfrontend.site_name'); $message .= ". Your two factor authorization login code is "; $message .= $codeToInput; $this->shortMessageService->sendSMS($data['phone_country_code'], $data['phone_number'], $message); }
[ "public", "function", "doTwoFactorAuthRegistration", "(", "$", "data", ")", "{", "// Get the 2FA code", "$", "codeToInput", "=", "$", "this", "->", "getCodeToInput", "(", ")", ";", "// Set this 2FA code into a session variable, since", "// this is the only opportunity to so save the ephemerally generated 2FA", "$", "this", "->", "request", "->", "session", "(", ")", "->", "put", "(", "'codeToInput'", ",", "$", "codeToInput", ")", ";", "// Put together the SMS message", "$", "message", "=", "config", "(", "'lasallecmsfrontend.site_name'", ")", ";", "$", "message", ".=", "\". Your two factor authorization login code is \"", ";", "$", "message", ".=", "$", "codeToInput", ";", "$", "this", "->", "shortMessageService", "->", "sendSMS", "(", "$", "data", "[", "'phone_country_code'", "]", ",", "$", "data", "[", "'phone_number'", "]", ",", "$", "message", ")", ";", "}" ]
Two Factor Authorization for the front-end REGISTRATION @param array $data @return void
[ "Two", "Factor", "Authorization", "for", "the", "front", "-", "end", "REGISTRATION" ]
b5203d596e18e2566e7fdcd3f13868bb44a94c1d
https://github.com/lasallecms/lasallecms-l5-usermanagement-pkg/blob/b5203d596e18e2566e7fdcd3f13868bb44a94c1d/src/Helpers/TwoFactorAuthorization/TwoFactorAuthHelper.php#L110-L127
25,328
lasallecms/lasallecms-l5-usermanagement-pkg
src/Helpers/TwoFactorAuthorization/TwoFactorAuthHelper.php
TwoFactorAuthHelper.isTwoFactorAuthFormTimeout
public function isTwoFactorAuthFormTimeout($userId=null, $startTime=null ) { if (isset($userId)) { // User wants to login, performing 2FA for this login $startTime = strtotime($this->getUserSmsTokenCreatedAt($userId)); } else { // New front-end registration, performing 2FA for this registration $startTime = strtotime($startTime); } $now = strtotime(Carbon::now()); // The time difference is in seconds, we want in minutes $timeDiff = ($now - $startTime)/60; $minutes2faFormIsLive = config('lasallecmsusermanagement.auth_2fa_minutes_smscode_is_live'); if ($timeDiff > $minutes2faFormIsLive) { if (isset($userId)) { // clear out the user's 2FA sms code and timestamp $this->clearUserTwoFactorAuthFields($userId); // clear the user_id session variable $this->clearUserIdSessionVar(); } else { $this->clearTwoFactorAuthCodeToInput(); } return true; } return false; }
php
public function isTwoFactorAuthFormTimeout($userId=null, $startTime=null ) { if (isset($userId)) { // User wants to login, performing 2FA for this login $startTime = strtotime($this->getUserSmsTokenCreatedAt($userId)); } else { // New front-end registration, performing 2FA for this registration $startTime = strtotime($startTime); } $now = strtotime(Carbon::now()); // The time difference is in seconds, we want in minutes $timeDiff = ($now - $startTime)/60; $minutes2faFormIsLive = config('lasallecmsusermanagement.auth_2fa_minutes_smscode_is_live'); if ($timeDiff > $minutes2faFormIsLive) { if (isset($userId)) { // clear out the user's 2FA sms code and timestamp $this->clearUserTwoFactorAuthFields($userId); // clear the user_id session variable $this->clearUserIdSessionVar(); } else { $this->clearTwoFactorAuthCodeToInput(); } return true; } return false; }
[ "public", "function", "isTwoFactorAuthFormTimeout", "(", "$", "userId", "=", "null", ",", "$", "startTime", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "userId", ")", ")", "{", "// User wants to login, performing 2FA for this login", "$", "startTime", "=", "strtotime", "(", "$", "this", "->", "getUserSmsTokenCreatedAt", "(", "$", "userId", ")", ")", ";", "}", "else", "{", "// New front-end registration, performing 2FA for this registration", "$", "startTime", "=", "strtotime", "(", "$", "startTime", ")", ";", "}", "$", "now", "=", "strtotime", "(", "Carbon", "::", "now", "(", ")", ")", ";", "// The time difference is in seconds, we want in minutes", "$", "timeDiff", "=", "(", "$", "now", "-", "$", "startTime", ")", "/", "60", ";", "$", "minutes2faFormIsLive", "=", "config", "(", "'lasallecmsusermanagement.auth_2fa_minutes_smscode_is_live'", ")", ";", "if", "(", "$", "timeDiff", ">", "$", "minutes2faFormIsLive", ")", "{", "if", "(", "isset", "(", "$", "userId", ")", ")", "{", "// clear out the user's 2FA sms code and timestamp", "$", "this", "->", "clearUserTwoFactorAuthFields", "(", "$", "userId", ")", ";", "// clear the user_id session variable", "$", "this", "->", "clearUserIdSessionVar", "(", ")", ";", "}", "else", "{", "$", "this", "->", "clearTwoFactorAuthCodeToInput", "(", ")", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}" ]
Has too much time passed between issuing the 2FA code and this code being entered into the verification form? @param int $userId User ID --> if null, then called by 2FA registration @param datetime $startTime Time 2FA form created --> if null, then called by 2FA login @return bool
[ "Has", "too", "much", "time", "passed", "between", "issuing", "the", "2FA", "code", "and", "this", "code", "being", "entered", "into", "the", "verification", "form?" ]
b5203d596e18e2566e7fdcd3f13868bb44a94c1d
https://github.com/lasallecms/lasallecms-l5-usermanagement-pkg/blob/b5203d596e18e2566e7fdcd3f13868bb44a94c1d/src/Helpers/TwoFactorAuthorization/TwoFactorAuthHelper.php#L137-L172
25,329
lasallecms/lasallecms-l5-usermanagement-pkg
src/Helpers/TwoFactorAuthorization/TwoFactorAuthHelper.php
TwoFactorAuthHelper.isInputtedTwoFactorAuthCodeCorrect
public function isInputtedTwoFactorAuthCodeCorrect($userId=null) { $inputted2faCode = $this->request->input('2facode'); if (isset($userId)) { $sent2faCode = $this->getUserSmsToken($userId); } else { $sent2faCode = $this->request->session()->get('codeToInput'); } if ($inputted2faCode == $sent2faCode) { return true; } return false; }
php
public function isInputtedTwoFactorAuthCodeCorrect($userId=null) { $inputted2faCode = $this->request->input('2facode'); if (isset($userId)) { $sent2faCode = $this->getUserSmsToken($userId); } else { $sent2faCode = $this->request->session()->get('codeToInput'); } if ($inputted2faCode == $sent2faCode) { return true; } return false; }
[ "public", "function", "isInputtedTwoFactorAuthCodeCorrect", "(", "$", "userId", "=", "null", ")", "{", "$", "inputted2faCode", "=", "$", "this", "->", "request", "->", "input", "(", "'2facode'", ")", ";", "if", "(", "isset", "(", "$", "userId", ")", ")", "{", "$", "sent2faCode", "=", "$", "this", "->", "getUserSmsToken", "(", "$", "userId", ")", ";", "}", "else", "{", "$", "sent2faCode", "=", "$", "this", "->", "request", "->", "session", "(", ")", "->", "get", "(", "'codeToInput'", ")", ";", "}", "if", "(", "$", "inputted2faCode", "==", "$", "sent2faCode", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Did the user input the correct 2FA code? @param int $userId User ID --> if null, then called by 2FA registration; otherwise, called by 2FA login @return bool
[ "Did", "the", "user", "input", "the", "correct", "2FA", "code?" ]
b5203d596e18e2566e7fdcd3f13868bb44a94c1d
https://github.com/lasallecms/lasallecms-l5-usermanagement-pkg/blob/b5203d596e18e2566e7fdcd3f13868bb44a94c1d/src/Helpers/TwoFactorAuthorization/TwoFactorAuthHelper.php#L182-L197
25,330
lasallecms/lasallecms-l5-usermanagement-pkg
src/Helpers/TwoFactorAuthorization/TwoFactorAuthHelper.php
TwoFactorAuthHelper.isUserTwoFactorAuthEnabled
public function isUserTwoFactorAuthEnabled($userId) { $result = DB::table('users') ->where('id', '=', $userId) ->value('two_factor_auth_enabled') ; if ($result) { return true; } return false; }
php
public function isUserTwoFactorAuthEnabled($userId) { $result = DB::table('users') ->where('id', '=', $userId) ->value('two_factor_auth_enabled') ; if ($result) { return true; } return false; }
[ "public", "function", "isUserTwoFactorAuthEnabled", "(", "$", "userId", ")", "{", "$", "result", "=", "DB", "::", "table", "(", "'users'", ")", "->", "where", "(", "'id'", ",", "'='", ",", "$", "userId", ")", "->", "value", "(", "'two_factor_auth_enabled'", ")", ";", "if", "(", "$", "result", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Is user enabled for Two Factor Authorization @param int $userId User ID @return bool
[ "Is", "user", "enabled", "for", "Two", "Factor", "Authorization" ]
b5203d596e18e2566e7fdcd3f13868bb44a94c1d
https://github.com/lasallecms/lasallecms-l5-usermanagement-pkg/blob/b5203d596e18e2566e7fdcd3f13868bb44a94c1d/src/Helpers/TwoFactorAuthorization/TwoFactorAuthHelper.php#L253-L263
25,331
lasallecms/lasallecms-l5-usermanagement-pkg
src/Helpers/TwoFactorAuthorization/TwoFactorAuthHelper.php
TwoFactorAuthHelper.existstUserCountryCodeAndPhoneNumber
public function existstUserCountryCodeAndPhoneNumber($userId) { $countryCode = DB::table('users') ->where('id', '=', $userId) ->value('phone_country_code') ; $phoneNumber = DB::table('users') ->where('id', '=', $userId) ->value('phone_number') ; if ((!$countryCode) || (!$phoneNumber)) { return false; } return true; }
php
public function existstUserCountryCodeAndPhoneNumber($userId) { $countryCode = DB::table('users') ->where('id', '=', $userId) ->value('phone_country_code') ; $phoneNumber = DB::table('users') ->where('id', '=', $userId) ->value('phone_number') ; if ((!$countryCode) || (!$phoneNumber)) { return false; } return true; }
[ "public", "function", "existstUserCountryCodeAndPhoneNumber", "(", "$", "userId", ")", "{", "$", "countryCode", "=", "DB", "::", "table", "(", "'users'", ")", "->", "where", "(", "'id'", ",", "'='", ",", "$", "userId", ")", "->", "value", "(", "'phone_country_code'", ")", ";", "$", "phoneNumber", "=", "DB", "::", "table", "(", "'users'", ")", "->", "where", "(", "'id'", ",", "'='", ",", "$", "userId", ")", "->", "value", "(", "'phone_number'", ")", ";", "if", "(", "(", "!", "$", "countryCode", ")", "||", "(", "!", "$", "phoneNumber", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Does the user have a country code and phone number for 2FA? @param int $userId User ID
[ "Does", "the", "user", "have", "a", "country", "code", "and", "phone", "number", "for", "2FA?" ]
b5203d596e18e2566e7fdcd3f13868bb44a94c1d
https://github.com/lasallecms/lasallecms-l5-usermanagement-pkg/blob/b5203d596e18e2566e7fdcd3f13868bb44a94c1d/src/Helpers/TwoFactorAuthorization/TwoFactorAuthHelper.php#L270-L286
25,332
lasallecms/lasallecms-l5-usermanagement-pkg
src/Helpers/TwoFactorAuthorization/TwoFactorAuthHelper.php
TwoFactorAuthHelper.updateUserRecordWithTwoFactorAuthCode
public function updateUserRecordWithTwoFactorAuthCode($codeToInput, $userId) { $now = Carbon::now(); DB::table('users') ->where('id', $userId) ->update(['sms_token' => $codeToInput, 'sms_token_created_at' => $now] ) ; }
php
public function updateUserRecordWithTwoFactorAuthCode($codeToInput, $userId) { $now = Carbon::now(); DB::table('users') ->where('id', $userId) ->update(['sms_token' => $codeToInput, 'sms_token_created_at' => $now] ) ; }
[ "public", "function", "updateUserRecordWithTwoFactorAuthCode", "(", "$", "codeToInput", ",", "$", "userId", ")", "{", "$", "now", "=", "Carbon", "::", "now", "(", ")", ";", "DB", "::", "table", "(", "'users'", ")", "->", "where", "(", "'id'", ",", "$", "userId", ")", "->", "update", "(", "[", "'sms_token'", "=>", "$", "codeToInput", ",", "'sms_token_created_at'", "=>", "$", "now", "]", ")", ";", "}" ]
UPDATE the user record for fields "sms_token" and "sms_token_created_at" @param text $codeToInput The code sent to the user via sms that has to be entered into a form to allow login @param int $userId User ID @return void
[ "UPDATE", "the", "user", "record", "for", "fields", "sms_token", "and", "sms_token_created_at" ]
b5203d596e18e2566e7fdcd3f13868bb44a94c1d
https://github.com/lasallecms/lasallecms-l5-usermanagement-pkg/blob/b5203d596e18e2566e7fdcd3f13868bb44a94c1d/src/Helpers/TwoFactorAuthorization/TwoFactorAuthHelper.php#L344-L352
25,333
lasallecms/lasallecms-l5-usermanagement-pkg
src/Helpers/TwoFactorAuthorization/TwoFactorAuthHelper.php
TwoFactorAuthHelper.updateUserRecordWithLastlogin
public function updateUserRecordWithLastlogin($userId) { $now = Carbon::now(); $ip = $this->request->getClientIp(); DB::table('users') ->where('id', $userId) ->update(['last_login' => $now, 'last_login_ip' => $ip] ) ; }
php
public function updateUserRecordWithLastlogin($userId) { $now = Carbon::now(); $ip = $this->request->getClientIp(); DB::table('users') ->where('id', $userId) ->update(['last_login' => $now, 'last_login_ip' => $ip] ) ; }
[ "public", "function", "updateUserRecordWithLastlogin", "(", "$", "userId", ")", "{", "$", "now", "=", "Carbon", "::", "now", "(", ")", ";", "$", "ip", "=", "$", "this", "->", "request", "->", "getClientIp", "(", ")", ";", "DB", "::", "table", "(", "'users'", ")", "->", "where", "(", "'id'", ",", "$", "userId", ")", "->", "update", "(", "[", "'last_login'", "=>", "$", "now", ",", "'last_login_ip'", "=>", "$", "ip", "]", ")", ";", "}" ]
UPDATE the user record for fields "last_login" and "last_login_ip" This method is here because it is convenient, as this class is already injected in the auth classes @param int $userId User ID @return void
[ "UPDATE", "the", "user", "record", "for", "fields", "last_login", "and", "last_login_ip" ]
b5203d596e18e2566e7fdcd3f13868bb44a94c1d
https://github.com/lasallecms/lasallecms-l5-usermanagement-pkg/blob/b5203d596e18e2566e7fdcd3f13868bb44a94c1d/src/Helpers/TwoFactorAuthorization/TwoFactorAuthHelper.php#L386-L395
25,334
lasallecms/lasallecms-l5-usermanagement-pkg
src/Helpers/TwoFactorAuthorization/TwoFactorAuthHelper.php
TwoFactorAuthHelper.redirectPathUponSuccessfulFrontendLogin
public function redirectPathUponSuccessfulFrontendLogin() { if (property_exists($this, 'redirectPath')) { return $this->redirectPath; } if (property_exists($this, 'redirectPath')) { return $this->redirectTo; } if (config('lasasllecmsfrontend.frontend_redirect_to_this_view_when_user_successfully_logged_in_to_front_end') != '') { return config('lasasllecmsfrontend.frontend_redirect_to_this_view_when_user_successfully_logged_in_to_front_end'); } return '/home'; }
php
public function redirectPathUponSuccessfulFrontendLogin() { if (property_exists($this, 'redirectPath')) { return $this->redirectPath; } if (property_exists($this, 'redirectPath')) { return $this->redirectTo; } if (config('lasasllecmsfrontend.frontend_redirect_to_this_view_when_user_successfully_logged_in_to_front_end') != '') { return config('lasasllecmsfrontend.frontend_redirect_to_this_view_when_user_successfully_logged_in_to_front_end'); } return '/home'; }
[ "public", "function", "redirectPathUponSuccessfulFrontendLogin", "(", ")", "{", "if", "(", "property_exists", "(", "$", "this", ",", "'redirectPath'", ")", ")", "{", "return", "$", "this", "->", "redirectPath", ";", "}", "if", "(", "property_exists", "(", "$", "this", ",", "'redirectPath'", ")", ")", "{", "return", "$", "this", "->", "redirectTo", ";", "}", "if", "(", "config", "(", "'lasasllecmsfrontend.frontend_redirect_to_this_view_when_user_successfully_logged_in_to_front_end'", ")", "!=", "''", ")", "{", "return", "config", "(", "'lasasllecmsfrontend.frontend_redirect_to_this_view_when_user_successfully_logged_in_to_front_end'", ")", ";", "}", "return", "'/home'", ";", "}" ]
Upon successful front-end login, redirect to this path @return string
[ "Upon", "successful", "front", "-", "end", "login", "redirect", "to", "this", "path" ]
b5203d596e18e2566e7fdcd3f13868bb44a94c1d
https://github.com/lasallecms/lasallecms-l5-usermanagement-pkg/blob/b5203d596e18e2566e7fdcd3f13868bb44a94c1d/src/Helpers/TwoFactorAuthorization/TwoFactorAuthHelper.php#L495-L510
25,335
apioo/psx-validate
src/Validate.php
Validate.apply
public function apply($value, $type = self::TYPE_STRING, array $filters = array(), $title = null, $required = true) { $result = $this->validate($value, $type, $filters, $title, $required); if ($result->hasError()) { throw new ValidationException($result->getFirstError(), $title, $result); } elseif ($result->isSuccessful()) { return $result->getValue(); } return null; }
php
public function apply($value, $type = self::TYPE_STRING, array $filters = array(), $title = null, $required = true) { $result = $this->validate($value, $type, $filters, $title, $required); if ($result->hasError()) { throw new ValidationException($result->getFirstError(), $title, $result); } elseif ($result->isSuccessful()) { return $result->getValue(); } return null; }
[ "public", "function", "apply", "(", "$", "value", ",", "$", "type", "=", "self", "::", "TYPE_STRING", ",", "array", "$", "filters", "=", "array", "(", ")", ",", "$", "title", "=", "null", ",", "$", "required", "=", "true", ")", "{", "$", "result", "=", "$", "this", "->", "validate", "(", "$", "value", ",", "$", "type", ",", "$", "filters", ",", "$", "title", ",", "$", "required", ")", ";", "if", "(", "$", "result", "->", "hasError", "(", ")", ")", "{", "throw", "new", "ValidationException", "(", "$", "result", "->", "getFirstError", "(", ")", ",", "$", "title", ",", "$", "result", ")", ";", "}", "elseif", "(", "$", "result", "->", "isSuccessful", "(", ")", ")", "{", "return", "$", "result", "->", "getValue", "(", ")", ";", "}", "return", "null", ";", "}" ]
Applies filter on the given value and returns the value on success or throws an exception if an error occured @param string $value @param string $type @param \PSX\Validate\FilterInterface[]|callable $filters @param string $title @param boolean $required @return mixed
[ "Applies", "filter", "on", "the", "given", "value", "and", "returns", "the", "value", "on", "success", "or", "throws", "an", "exception", "if", "an", "error", "occured" ]
4860c6a2c7f7ca52d3bd6d7e6ec7d6a7ddcfd83d
https://github.com/apioo/psx-validate/blob/4860c6a2c7f7ca52d3bd6d7e6ec7d6a7ddcfd83d/src/Validate.php#L53-L64
25,336
LartTyler/PHP-DaybreakCommons
src/DaybreakStudios/Common/Utility/Counter.php
Counter.clear
public function clear($key = null) { if ($key === null) $this->counts->clear(); else $this->counts->remove($key); }
php
public function clear($key = null) { if ($key === null) $this->counts->clear(); else $this->counts->remove($key); }
[ "public", "function", "clear", "(", "$", "key", "=", "null", ")", "{", "if", "(", "$", "key", "===", "null", ")", "$", "this", "->", "counts", "->", "clear", "(", ")", ";", "else", "$", "this", "->", "counts", "->", "remove", "(", "$", "key", ")", ";", "}" ]
Clears the given key, or the entire counter if the key is not given. @param mixed $key the key to clear; pass null to clear the entire counter
[ "Clears", "the", "given", "key", "or", "the", "entire", "counter", "if", "the", "key", "is", "not", "given", "." ]
db25b5d6cea9b5a1d5afc4c5548a2cbc3018bc0d
https://github.com/LartTyler/PHP-DaybreakCommons/blob/db25b5d6cea9b5a1d5afc4c5548a2cbc3018bc0d/src/DaybreakStudios/Common/Utility/Counter.php#L61-L66
25,337
LartTyler/PHP-DaybreakCommons
src/DaybreakStudios/Common/Utility/Counter.php
Counter.add
public function add($key, $amount) { if (!$this->allowed($key)) throw new OutOfBoundsException(sprintf('"%s" is not an allowed key in strict mode', $key)); else if (!$this->has($key)) $this->counts->put($key, 0); $this->counts->put($key, $this->counts->get($key) + $amount); return $this->counts->get($key); }
php
public function add($key, $amount) { if (!$this->allowed($key)) throw new OutOfBoundsException(sprintf('"%s" is not an allowed key in strict mode', $key)); else if (!$this->has($key)) $this->counts->put($key, 0); $this->counts->put($key, $this->counts->get($key) + $amount); return $this->counts->get($key); }
[ "public", "function", "add", "(", "$", "key", ",", "$", "amount", ")", "{", "if", "(", "!", "$", "this", "->", "allowed", "(", "$", "key", ")", ")", "throw", "new", "OutOfBoundsException", "(", "sprintf", "(", "'\"%s\" is not an allowed key in strict mode'", ",", "$", "key", ")", ")", ";", "else", "if", "(", "!", "$", "this", "->", "has", "(", "$", "key", ")", ")", "$", "this", "->", "counts", "->", "put", "(", "$", "key", ",", "0", ")", ";", "$", "this", "->", "counts", "->", "put", "(", "$", "key", ",", "$", "this", "->", "counts", "->", "get", "(", "$", "key", ")", "+", "$", "amount", ")", ";", "return", "$", "this", "->", "counts", "->", "get", "(", "$", "key", ")", ";", "}" ]
Adds the given amount to a key. If the key does not exist and the counter is not running in strict mode, it will be initialized to zero. @throws OutOfBoundsException if the counter is in strict mode and the key was not defined at construction @param mixed $key the key to add to @param int|float $amount the amount to add to the key @return int|float the new value of the key
[ "Adds", "the", "given", "amount", "to", "a", "key", ".", "If", "the", "key", "does", "not", "exist", "and", "the", "counter", "is", "not", "running", "in", "strict", "mode", "it", "will", "be", "initialized", "to", "zero", "." ]
db25b5d6cea9b5a1d5afc4c5548a2cbc3018bc0d
https://github.com/LartTyler/PHP-DaybreakCommons/blob/db25b5d6cea9b5a1d5afc4c5548a2cbc3018bc0d/src/DaybreakStudios/Common/Utility/Counter.php#L78-L87
25,338
staticka/staticka
src/Page.php
Page.uris
public function uris() { $uri = (string) $this->uri; $exists = isset($this->data['permalink']); $exists && $uri = $this->data['permalink']; $items = explode('/', (string) $uri); $items = array_filter((array) $items); return (array) array_values($items); }
php
public function uris() { $uri = (string) $this->uri; $exists = isset($this->data['permalink']); $exists && $uri = $this->data['permalink']; $items = explode('/', (string) $uri); $items = array_filter((array) $items); return (array) array_values($items); }
[ "public", "function", "uris", "(", ")", "{", "$", "uri", "=", "(", "string", ")", "$", "this", "->", "uri", ";", "$", "exists", "=", "isset", "(", "$", "this", "->", "data", "[", "'permalink'", "]", ")", ";", "$", "exists", "&&", "$", "uri", "=", "$", "this", "->", "data", "[", "'permalink'", "]", ";", "$", "items", "=", "explode", "(", "'/'", ",", "(", "string", ")", "$", "uri", ")", ";", "$", "items", "=", "array_filter", "(", "(", "array", ")", "$", "items", ")", ";", "return", "(", "array", ")", "array_values", "(", "$", "items", ")", ";", "}" ]
Returns an array of URI segments. @return array
[ "Returns", "an", "array", "of", "URI", "segments", "." ]
6e3b814c391ed03b0bd409803e11579bae677ce4
https://github.com/staticka/staticka/blob/6e3b814c391ed03b0bd409803e11579bae677ce4/src/Page.php#L80-L93
25,339
staticka/staticka
src/Page.php
Page.layout
public function layout() { $exists = (boolean) isset($this->data['layout']); return $exists ? $this->data['layout'] : null; }
php
public function layout() { $exists = (boolean) isset($this->data['layout']); return $exists ? $this->data['layout'] : null; }
[ "public", "function", "layout", "(", ")", "{", "$", "exists", "=", "(", "boolean", ")", "isset", "(", "$", "this", "->", "data", "[", "'layout'", "]", ")", ";", "return", "$", "exists", "?", "$", "this", "->", "data", "[", "'layout'", "]", ":", "null", ";", "}" ]
Returns the layout of the page. @return string|null
[ "Returns", "the", "layout", "of", "the", "page", "." ]
6e3b814c391ed03b0bd409803e11579bae677ce4
https://github.com/staticka/staticka/blob/6e3b814c391ed03b0bd409803e11579bae677ce4/src/Page.php#L100-L105
25,340
kaiohken1982/Neobazaar
src/Neobazaar/Entity/Repository/UserRepository.php
UserRepository.getPaginator
public function getPaginator($params = array()) { $page = isset($params['page']) ? (int)$params['page'] : 1; $email = isset($params['email']) ? $params['email'] : null; $limit = isset($params['limit']) ? (int) $params['limit'] : 10; $offset = isset($params['offset']) ? (int) $params['offset'] : 0; $qb = $this->_em->createQueryBuilder(); $qb->select(array('a')); $qb->from($this->getEntityName(), 'a'); $qb->addOrderBy('a.dateInsert', 'DESC'); if(null !== $email) { $qb->andWhere($qb->expr()->eq('a.email', ':paramEmail')); $qb->setParameter('paramEmail', $email); } $query = $qb->getQuery(); $query->setFirstResult($offset); $query->setMaxResults($limit); // $paginator = new DoctrinePaginator($query, $fetchJoinCollection = true); // $result = array(); // foreach($paginator as $p) { // $result[] = $p->getUserId(); // } // $result = $query->getResult(); // $paginatorAdapter = new RazorPaginator( // $result, // count($paginator) // ); $paginatorAdapter = new DoctrinePaginatorAdapter(new DoctrinePaginator($query)); $paginator = new Paginator($paginatorAdapter); $paginator->setCurrentPageNumber($page); $paginator->setDefaultItemCountPerPage($limit); return $paginator; }
php
public function getPaginator($params = array()) { $page = isset($params['page']) ? (int)$params['page'] : 1; $email = isset($params['email']) ? $params['email'] : null; $limit = isset($params['limit']) ? (int) $params['limit'] : 10; $offset = isset($params['offset']) ? (int) $params['offset'] : 0; $qb = $this->_em->createQueryBuilder(); $qb->select(array('a')); $qb->from($this->getEntityName(), 'a'); $qb->addOrderBy('a.dateInsert', 'DESC'); if(null !== $email) { $qb->andWhere($qb->expr()->eq('a.email', ':paramEmail')); $qb->setParameter('paramEmail', $email); } $query = $qb->getQuery(); $query->setFirstResult($offset); $query->setMaxResults($limit); // $paginator = new DoctrinePaginator($query, $fetchJoinCollection = true); // $result = array(); // foreach($paginator as $p) { // $result[] = $p->getUserId(); // } // $result = $query->getResult(); // $paginatorAdapter = new RazorPaginator( // $result, // count($paginator) // ); $paginatorAdapter = new DoctrinePaginatorAdapter(new DoctrinePaginator($query)); $paginator = new Paginator($paginatorAdapter); $paginator->setCurrentPageNumber($page); $paginator->setDefaultItemCountPerPage($limit); return $paginator; }
[ "public", "function", "getPaginator", "(", "$", "params", "=", "array", "(", ")", ")", "{", "$", "page", "=", "isset", "(", "$", "params", "[", "'page'", "]", ")", "?", "(", "int", ")", "$", "params", "[", "'page'", "]", ":", "1", ";", "$", "email", "=", "isset", "(", "$", "params", "[", "'email'", "]", ")", "?", "$", "params", "[", "'email'", "]", ":", "null", ";", "$", "limit", "=", "isset", "(", "$", "params", "[", "'limit'", "]", ")", "?", "(", "int", ")", "$", "params", "[", "'limit'", "]", ":", "10", ";", "$", "offset", "=", "isset", "(", "$", "params", "[", "'offset'", "]", ")", "?", "(", "int", ")", "$", "params", "[", "'offset'", "]", ":", "0", ";", "$", "qb", "=", "$", "this", "->", "_em", "->", "createQueryBuilder", "(", ")", ";", "$", "qb", "->", "select", "(", "array", "(", "'a'", ")", ")", ";", "$", "qb", "->", "from", "(", "$", "this", "->", "getEntityName", "(", ")", ",", "'a'", ")", ";", "$", "qb", "->", "addOrderBy", "(", "'a.dateInsert'", ",", "'DESC'", ")", ";", "if", "(", "null", "!==", "$", "email", ")", "{", "$", "qb", "->", "andWhere", "(", "$", "qb", "->", "expr", "(", ")", "->", "eq", "(", "'a.email'", ",", "':paramEmail'", ")", ")", ";", "$", "qb", "->", "setParameter", "(", "'paramEmail'", ",", "$", "email", ")", ";", "}", "$", "query", "=", "$", "qb", "->", "getQuery", "(", ")", ";", "$", "query", "->", "setFirstResult", "(", "$", "offset", ")", ";", "$", "query", "->", "setMaxResults", "(", "$", "limit", ")", ";", "// \t\t$paginator = new DoctrinePaginator($query, $fetchJoinCollection = true);", "// \t\t$result = array();", "// \t\tforeach($paginator as $p) {", "// \t\t\t$result[] = $p->getUserId();", "// \t\t}", "// \t\t$result = $query->getResult();", "// \t\t$paginatorAdapter = new RazorPaginator(", "// \t\t\t$result,", "// \t\t\tcount($paginator)", "// \t\t);", "$", "paginatorAdapter", "=", "new", "DoctrinePaginatorAdapter", "(", "new", "DoctrinePaginator", "(", "$", "query", ")", ")", ";", "$", "paginator", "=", "new", "Paginator", "(", "$", "paginatorAdapter", ")", ";", "$", "paginator", "->", "setCurrentPageNumber", "(", "$", "page", ")", ";", "$", "paginator", "->", "setDefaultItemCountPerPage", "(", "$", "limit", ")", ";", "return", "$", "paginator", ";", "}" ]
Return the paginator @param array $params @return \Zend\Paginator\Paginator
[ "Return", "the", "paginator" ]
288c972dea981d715c4e136edb5dba0318c9e6cb
https://github.com/kaiohken1982/Neobazaar/blob/288c972dea981d715c4e136edb5dba0318c9e6cb/src/Neobazaar/Entity/Repository/UserRepository.php#L112-L149
25,341
bytic/auth
src/Models/Users/Traits/Authentication/AuthenticationUserTrait.php
AuthenticationUserTrait.authenticate
public function authenticate($request = []) { if ($request) { $this->email = clean($request['email']); $this->password = $this->getPasswordHelper()->hash(clean($request['password'])); } else { $this->password = $this->getPasswordHelper()->hash(clean($this->password)); } $query = $this->getManager()->newQuery(); $query->where("email = ?", $this->email); $query->where("password = ?", $this->password); /** @var User $user */ $user = $this->getManager()->findOneByQuery($query); if ($user) { $this->writeData($user->toArray()); $this->doAuthentication(); } return $this->authenticated(); }
php
public function authenticate($request = []) { if ($request) { $this->email = clean($request['email']); $this->password = $this->getPasswordHelper()->hash(clean($request['password'])); } else { $this->password = $this->getPasswordHelper()->hash(clean($this->password)); } $query = $this->getManager()->newQuery(); $query->where("email = ?", $this->email); $query->where("password = ?", $this->password); /** @var User $user */ $user = $this->getManager()->findOneByQuery($query); if ($user) { $this->writeData($user->toArray()); $this->doAuthentication(); } return $this->authenticated(); }
[ "public", "function", "authenticate", "(", "$", "request", "=", "[", "]", ")", "{", "if", "(", "$", "request", ")", "{", "$", "this", "->", "email", "=", "clean", "(", "$", "request", "[", "'email'", "]", ")", ";", "$", "this", "->", "password", "=", "$", "this", "->", "getPasswordHelper", "(", ")", "->", "hash", "(", "clean", "(", "$", "request", "[", "'password'", "]", ")", ")", ";", "}", "else", "{", "$", "this", "->", "password", "=", "$", "this", "->", "getPasswordHelper", "(", ")", "->", "hash", "(", "clean", "(", "$", "this", "->", "password", ")", ")", ";", "}", "$", "query", "=", "$", "this", "->", "getManager", "(", ")", "->", "newQuery", "(", ")", ";", "$", "query", "->", "where", "(", "\"email = ?\"", ",", "$", "this", "->", "email", ")", ";", "$", "query", "->", "where", "(", "\"password = ?\"", ",", "$", "this", "->", "password", ")", ";", "/** @var User $user */", "$", "user", "=", "$", "this", "->", "getManager", "(", ")", "->", "findOneByQuery", "(", "$", "query", ")", ";", "if", "(", "$", "user", ")", "{", "$", "this", "->", "writeData", "(", "$", "user", "->", "toArray", "(", ")", ")", ";", "$", "this", "->", "doAuthentication", "(", ")", ";", "}", "return", "$", "this", "->", "authenticated", "(", ")", ";", "}" ]
Authenticate user from request @param array $request @return bool|null
[ "Authenticate", "user", "from", "request" ]
c155687840e9cd160e0c55a94f24a3608f72604c
https://github.com/bytic/auth/blob/c155687840e9cd160e0c55a94f24a3608f72604c/src/Models/Users/Traits/Authentication/AuthenticationUserTrait.php#L36-L59
25,342
OxfordInfoLabs/kinikit-core
src/Util/Multithreading/Thread.php
Thread.run
public function run($parameters = array()) { // Grab a process ID for a new forked process $this->pid = \pcntl_fork(); if (!$this->pid) { $this->process($parameters); posix_kill(getmypid(), 9); } return $this->pid; }
php
public function run($parameters = array()) { // Grab a process ID for a new forked process $this->pid = \pcntl_fork(); if (!$this->pid) { $this->process($parameters); posix_kill(getmypid(), 9); } return $this->pid; }
[ "public", "function", "run", "(", "$", "parameters", "=", "array", "(", ")", ")", "{", "// Grab a process ID for a new forked process", "$", "this", "->", "pid", "=", "\\", "pcntl_fork", "(", ")", ";", "if", "(", "!", "$", "this", "->", "pid", ")", "{", "$", "this", "->", "process", "(", "$", "parameters", ")", ";", "posix_kill", "(", "getmypid", "(", ")", ",", "9", ")", ";", "}", "return", "$", "this", "->", "pid", ";", "}" ]
Main run method called to start the thread.
[ "Main", "run", "method", "called", "to", "start", "the", "thread", "." ]
edc1b2e6ffabd595c4c7d322279b3dd1e59ef359
https://github.com/OxfordInfoLabs/kinikit-core/blob/edc1b2e6ffabd595c4c7d322279b3dd1e59ef359/src/Util/Multithreading/Thread.php#L22-L33
25,343
OxfordInfoLabs/kinikit-core
src/Util/Multithreading/Thread.php
Thread.wait
public function wait() { if ($this->pid) { \pcntl_waitpid($this->pid, $status, WUNTRACED); return $status; } else { return false; } }
php
public function wait() { if ($this->pid) { \pcntl_waitpid($this->pid, $status, WUNTRACED); return $status; } else { return false; } }
[ "public", "function", "wait", "(", ")", "{", "if", "(", "$", "this", "->", "pid", ")", "{", "\\", "pcntl_waitpid", "(", "$", "this", "->", "pid", ",", "$", "status", ",", "WUNTRACED", ")", ";", "return", "$", "status", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Blocking method called by another thread which waits until this thread has completed.
[ "Blocking", "method", "called", "by", "another", "thread", "which", "waits", "until", "this", "thread", "has", "completed", "." ]
edc1b2e6ffabd595c4c7d322279b3dd1e59ef359
https://github.com/OxfordInfoLabs/kinikit-core/blob/edc1b2e6ffabd595c4c7d322279b3dd1e59ef359/src/Util/Multithreading/Thread.php#L40-L47
25,344
OxfordInfoLabs/kinikit-core
src/Util/Multithreading/Thread.php
Thread.getStatus
public function getStatus() { if ($this->pid) { $waitPID = \pcntl_waitpid($this->pid, $status, WNOHANG); if ($waitPID == $this->pid) { return Thread::THREAD_EXITED; } else { return Thread::THREAD_RUNNING; } } }
php
public function getStatus() { if ($this->pid) { $waitPID = \pcntl_waitpid($this->pid, $status, WNOHANG); if ($waitPID == $this->pid) { return Thread::THREAD_EXITED; } else { return Thread::THREAD_RUNNING; } } }
[ "public", "function", "getStatus", "(", ")", "{", "if", "(", "$", "this", "->", "pid", ")", "{", "$", "waitPID", "=", "\\", "pcntl_waitpid", "(", "$", "this", "->", "pid", ",", "$", "status", ",", "WNOHANG", ")", ";", "if", "(", "$", "waitPID", "==", "$", "this", "->", "pid", ")", "{", "return", "Thread", "::", "THREAD_EXITED", ";", "}", "else", "{", "return", "Thread", "::", "THREAD_RUNNING", ";", "}", "}", "}" ]
Get the current status for this thread.
[ "Get", "the", "current", "status", "for", "this", "thread", "." ]
edc1b2e6ffabd595c4c7d322279b3dd1e59ef359
https://github.com/OxfordInfoLabs/kinikit-core/blob/edc1b2e6ffabd595c4c7d322279b3dd1e59ef359/src/Util/Multithreading/Thread.php#L53-L63
25,345
miBadger/miBadger.Settings
src/Settings.php
Settings.load
public function load($path = self::DEFAULT_FILENAME) { $file = new File($path); if (($data = json_decode($file->read(), true)) === null) { throw new \UnexpectedValueException('Invalid JSON.'); } $this->data = (array) $data; return $this; }
php
public function load($path = self::DEFAULT_FILENAME) { $file = new File($path); if (($data = json_decode($file->read(), true)) === null) { throw new \UnexpectedValueException('Invalid JSON.'); } $this->data = (array) $data; return $this; }
[ "public", "function", "load", "(", "$", "path", "=", "self", "::", "DEFAULT_FILENAME", ")", "{", "$", "file", "=", "new", "File", "(", "$", "path", ")", ";", "if", "(", "(", "$", "data", "=", "json_decode", "(", "$", "file", "->", "read", "(", ")", ",", "true", ")", ")", "===", "null", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "'Invalid JSON.'", ")", ";", "}", "$", "this", "->", "data", "=", "(", "array", ")", "$", "data", ";", "return", "$", "this", ";", "}" ]
Load the settings file from the given location. @param $path = self::DEFAULT_FILENAME @return $this @throws FileException on failure. @throws \UnexpectedValueException on failure.
[ "Load", "the", "settings", "file", "from", "the", "given", "location", "." ]
dc2be14d96e2db84acb9fba543099380b1f14bd8
https://github.com/miBadger/miBadger.Settings/blob/dc2be14d96e2db84acb9fba543099380b1f14bd8/src/Settings.php#L144-L155
25,346
miBadger/miBadger.Settings
src/Settings.php
Settings.save
public function save($path = self::DEFAULT_FILENAME) { $file = new File($path); $file->write(json_encode($this->data)); return $this; }
php
public function save($path = self::DEFAULT_FILENAME) { $file = new File($path); $file->write(json_encode($this->data)); return $this; }
[ "public", "function", "save", "(", "$", "path", "=", "self", "::", "DEFAULT_FILENAME", ")", "{", "$", "file", "=", "new", "File", "(", "$", "path", ")", ";", "$", "file", "->", "write", "(", "json_encode", "(", "$", "this", "->", "data", ")", ")", ";", "return", "$", "this", ";", "}" ]
Save the settings file at the given location. @param $path = self::DEFAULT_FILENAME @return $this @throws FileException on failure.
[ "Save", "the", "settings", "file", "at", "the", "given", "location", "." ]
dc2be14d96e2db84acb9fba543099380b1f14bd8
https://github.com/miBadger/miBadger.Settings/blob/dc2be14d96e2db84acb9fba543099380b1f14bd8/src/Settings.php#L164-L171
25,347
wearenolte/wp-endpoints-routes
src/Routes.php
Routes.get_blog_routes
private function get_blog_routes() { $data = []; $blog_url = false; $home_url = home_url(); $page_on_front = get_option( 'page_on_front' ); $blog_page = get_option( 'page_for_posts' ); if ( ! $page_on_front ) { $blog_url = '/'; } elseif ( $blog_page ) { $blog_url = rtrim( str_replace( $home_url, '', get_permalink( $blog_page ) ), '/' ); } if ( $blog_url ) { $data[] = [ 'state' => 'blogIndex', 'url' => $blog_url, 'template' => 'blog', 'endpoint' => $this->get_wp_endpoint_route( 'posts' ), 'params' => apply_filters( self::FILTER_BLOG_PARAMS, [] ), ]; } // Create routes for single blog posts if active. $single_post_url = apply_filters( self::FILTER_SINGLE_POST_ROUTE, '/' === $blog_url ? '/blog' : $blog_url ); if ( $single_post_url ) { $data[] = [ 'state' => 'blogPost', 'url' => $single_post_url . '/:slug', 'template' => 'blog-single', 'endpoint' => $this->get_wp_endpoint_route( 'posts' ), ]; } return $data; }
php
private function get_blog_routes() { $data = []; $blog_url = false; $home_url = home_url(); $page_on_front = get_option( 'page_on_front' ); $blog_page = get_option( 'page_for_posts' ); if ( ! $page_on_front ) { $blog_url = '/'; } elseif ( $blog_page ) { $blog_url = rtrim( str_replace( $home_url, '', get_permalink( $blog_page ) ), '/' ); } if ( $blog_url ) { $data[] = [ 'state' => 'blogIndex', 'url' => $blog_url, 'template' => 'blog', 'endpoint' => $this->get_wp_endpoint_route( 'posts' ), 'params' => apply_filters( self::FILTER_BLOG_PARAMS, [] ), ]; } // Create routes for single blog posts if active. $single_post_url = apply_filters( self::FILTER_SINGLE_POST_ROUTE, '/' === $blog_url ? '/blog' : $blog_url ); if ( $single_post_url ) { $data[] = [ 'state' => 'blogPost', 'url' => $single_post_url . '/:slug', 'template' => 'blog-single', 'endpoint' => $this->get_wp_endpoint_route( 'posts' ), ]; } return $data; }
[ "private", "function", "get_blog_routes", "(", ")", "{", "$", "data", "=", "[", "]", ";", "$", "blog_url", "=", "false", ";", "$", "home_url", "=", "home_url", "(", ")", ";", "$", "page_on_front", "=", "get_option", "(", "'page_on_front'", ")", ";", "$", "blog_page", "=", "get_option", "(", "'page_for_posts'", ")", ";", "if", "(", "!", "$", "page_on_front", ")", "{", "$", "blog_url", "=", "'/'", ";", "}", "elseif", "(", "$", "blog_page", ")", "{", "$", "blog_url", "=", "rtrim", "(", "str_replace", "(", "$", "home_url", ",", "''", ",", "get_permalink", "(", "$", "blog_page", ")", ")", ",", "'/'", ")", ";", "}", "if", "(", "$", "blog_url", ")", "{", "$", "data", "[", "]", "=", "[", "'state'", "=>", "'blogIndex'", ",", "'url'", "=>", "$", "blog_url", ",", "'template'", "=>", "'blog'", ",", "'endpoint'", "=>", "$", "this", "->", "get_wp_endpoint_route", "(", "'posts'", ")", ",", "'params'", "=>", "apply_filters", "(", "self", "::", "FILTER_BLOG_PARAMS", ",", "[", "]", ")", ",", "]", ";", "}", "// Create routes for single blog posts if active.", "$", "single_post_url", "=", "apply_filters", "(", "self", "::", "FILTER_SINGLE_POST_ROUTE", ",", "'/'", "===", "$", "blog_url", "?", "'/blog'", ":", "$", "blog_url", ")", ";", "if", "(", "$", "single_post_url", ")", "{", "$", "data", "[", "]", "=", "[", "'state'", "=>", "'blogPost'", ",", "'url'", "=>", "$", "single_post_url", ".", "'/:slug'", ",", "'template'", "=>", "'blog-single'", ",", "'endpoint'", "=>", "$", "this", "->", "get_wp_endpoint_route", "(", "'posts'", ")", ",", "]", ";", "}", "return", "$", "data", ";", "}" ]
Create routes for the blog page and single posts if active.. @return array
[ "Create", "routes", "for", "the", "blog", "page", "and", "single", "posts", "if", "active", ".." ]
d86e77908f9d7ddc862d1a902cd8d2d7c0449473
https://github.com/wearenolte/wp-endpoints-routes/blob/d86e77908f9d7ddc862d1a902cd8d2d7c0449473/src/Routes.php#L91-L131
25,348
agentmedia/phine-core
src/Core/Modules/Backend/UserList.php
UserList.GroupsFormUrl
protected function GroupsFormUrl(User $user) { $args = array('user'=>$user->GetID()); return BackendRouter::ModuleUrl(new UsergroupAssignmentForm(), $args); }
php
protected function GroupsFormUrl(User $user) { $args = array('user'=>$user->GetID()); return BackendRouter::ModuleUrl(new UsergroupAssignmentForm(), $args); }
[ "protected", "function", "GroupsFormUrl", "(", "User", "$", "user", ")", "{", "$", "args", "=", "array", "(", "'user'", "=>", "$", "user", "->", "GetID", "(", ")", ")", ";", "return", "BackendRouter", "::", "ModuleUrl", "(", "new", "UsergroupAssignmentForm", "(", ")", ",", "$", "args", ")", ";", "}" ]
The url to the form for the user groups @param User $user @return string
[ "The", "url", "to", "the", "form", "for", "the", "user", "groups" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/UserList.php#L65-L69
25,349
agentmedia/phine-core
src/Core/Modules/Backend/UserList.php
UserList.RemovalObject
protected function RemovalObject() { $id = Request::PostData('delete'); return $id ? User::Schema()->ByID($id) : null; }
php
protected function RemovalObject() { $id = Request::PostData('delete'); return $id ? User::Schema()->ByID($id) : null; }
[ "protected", "function", "RemovalObject", "(", ")", "{", "$", "id", "=", "Request", "::", "PostData", "(", "'delete'", ")", ";", "return", "$", "id", "?", "User", "::", "Schema", "(", ")", "->", "ByID", "(", "$", "id", ")", ":", "null", ";", "}" ]
Gets the site for removal if delete id is posted @return User
[ "Gets", "the", "site", "for", "removal", "if", "delete", "id", "is", "posted" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/UserList.php#L104-L108
25,350
agentmedia/phine-core
src/Core/Modules/Backend/UserList.php
UserList.CanEdit
protected function CanEdit(User $user) { return self::Guard()->Allow(BackendAction::Edit(), $user)&& self::Guard()->Allow(BackendAction::UseIt(), new UserForm()); }
php
protected function CanEdit(User $user) { return self::Guard()->Allow(BackendAction::Edit(), $user)&& self::Guard()->Allow(BackendAction::UseIt(), new UserForm()); }
[ "protected", "function", "CanEdit", "(", "User", "$", "user", ")", "{", "return", "self", "::", "Guard", "(", ")", "->", "Allow", "(", "BackendAction", "::", "Edit", "(", ")", ",", "$", "user", ")", "&&", "self", "::", "Guard", "(", ")", "->", "Allow", "(", "BackendAction", "::", "UseIt", "(", ")", ",", "new", "UserForm", "(", ")", ")", ";", "}" ]
True if user can be edited @param User $user @return string
[ "True", "if", "user", "can", "be", "edited" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Modules/Backend/UserList.php#L121-L125
25,351
rutger-speksnijder/restphp
src/RestPHP/Response/Types/Text.php
Text.transformToText
private function transformToText($data, $hypertextRoutes = [], $depth = 0) { // Return the data as string if it's not an array if (!is_array($data)) { return "{$data}\n{$this->getHypertextString($hypertextRoutes)}"; } // Loop through the data and add to the string $str = ''; foreach ($data as $k => $v) { // Add tabs for ($i = 0; $i < $depth; $i++) { $str .= "\t"; } if (is_array($v)) { // Recursively transform underlying data $str .= "{$k}: {$this->transformToText($v, [], $depth+1)}\n"; } else { $str .= "{$k}: {$v}\n"; } } // Add the hypertext routes $str .= $this->getHypertextString($hypertextRoutes); return $str; }
php
private function transformToText($data, $hypertextRoutes = [], $depth = 0) { // Return the data as string if it's not an array if (!is_array($data)) { return "{$data}\n{$this->getHypertextString($hypertextRoutes)}"; } // Loop through the data and add to the string $str = ''; foreach ($data as $k => $v) { // Add tabs for ($i = 0; $i < $depth; $i++) { $str .= "\t"; } if (is_array($v)) { // Recursively transform underlying data $str .= "{$k}: {$this->transformToText($v, [], $depth+1)}\n"; } else { $str .= "{$k}: {$v}\n"; } } // Add the hypertext routes $str .= $this->getHypertextString($hypertextRoutes); return $str; }
[ "private", "function", "transformToText", "(", "$", "data", ",", "$", "hypertextRoutes", "=", "[", "]", ",", "$", "depth", "=", "0", ")", "{", "// Return the data as string if it's not an array", "if", "(", "!", "is_array", "(", "$", "data", ")", ")", "{", "return", "\"{$data}\\n{$this->getHypertextString($hypertextRoutes)}\"", ";", "}", "// Loop through the data and add to the string", "$", "str", "=", "''", ";", "foreach", "(", "$", "data", "as", "$", "k", "=>", "$", "v", ")", "{", "// Add tabs", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "depth", ";", "$", "i", "++", ")", "{", "$", "str", ".=", "\"\\t\"", ";", "}", "if", "(", "is_array", "(", "$", "v", ")", ")", "{", "// Recursively transform underlying data", "$", "str", ".=", "\"{$k}: {$this->transformToText($v, [], $depth+1)}\\n\"", ";", "}", "else", "{", "$", "str", ".=", "\"{$k}: {$v}\\n\"", ";", "}", "}", "// Add the hypertext routes", "$", "str", ".=", "$", "this", "->", "getHypertextString", "(", "$", "hypertextRoutes", ")", ";", "return", "$", "str", ";", "}" ]
Recursively converts the response into a text string. @param mixed $data The data to transform. @param optional array $hypertextRoutes An array with hypertext routes. @return string The response as a text string.
[ "Recursively", "converts", "the", "response", "into", "a", "text", "string", "." ]
326a7c0d79b266bbdd8a27ff1c8021caf9d28a3d
https://github.com/rutger-speksnijder/restphp/blob/326a7c0d79b266bbdd8a27ff1c8021caf9d28a3d/src/RestPHP/Response/Types/Text.php#L48-L74
25,352
rutger-speksnijder/restphp
src/RestPHP/Response/Types/Text.php
Text.getHypertextString
private function getHypertextString($routes = []) { // Check if we have routes if (!$routes) { return ''; } // Loop through the routes and add them to the string $str = "links: \n"; foreach ($routes as $name => $route) { $str .= "\trel: {$name}. href: {$route}.\n"; } return $str; }
php
private function getHypertextString($routes = []) { // Check if we have routes if (!$routes) { return ''; } // Loop through the routes and add them to the string $str = "links: \n"; foreach ($routes as $name => $route) { $str .= "\trel: {$name}. href: {$route}.\n"; } return $str; }
[ "private", "function", "getHypertextString", "(", "$", "routes", "=", "[", "]", ")", "{", "// Check if we have routes", "if", "(", "!", "$", "routes", ")", "{", "return", "''", ";", "}", "// Loop through the routes and add them to the string", "$", "str", "=", "\"links: \\n\"", ";", "foreach", "(", "$", "routes", "as", "$", "name", "=>", "$", "route", ")", "{", "$", "str", ".=", "\"\\trel: {$name}. href: {$route}.\\n\"", ";", "}", "return", "$", "str", ";", "}" ]
Transforms the hypertext routes into a string. @param array $routes The hypertext routes. @return string The hypertext routes transformed into a string.
[ "Transforms", "the", "hypertext", "routes", "into", "a", "string", "." ]
326a7c0d79b266bbdd8a27ff1c8021caf9d28a3d
https://github.com/rutger-speksnijder/restphp/blob/326a7c0d79b266bbdd8a27ff1c8021caf9d28a3d/src/RestPHP/Response/Types/Text.php#L83-L96
25,353
locomotivemtl/charcoal-queue
src/Charcoal/Queue/AbstractQueueManager.php
AbstractQueueManager.processQueue
public function processQueue(callable $callback = null) { $queued = $this->loadQueueItems(); if (!is_callable($callback)) { $callback = $this->processedCallback; } $success = []; $failures = []; $skipped = []; foreach ($queued as $q) { try { $res = $q->process($this->itemCallback, $this->itemSuccessCallback, $this->itemFailureCallback); if ($res === true) { $success[] = $q; } elseif ($res === false) { $failures[] = $q; } else { $skipped[] = $q; } } catch (Exception $e) { $this->logger->error( sprintf('Could not process a queue item: %s', $e->getMessage()) ); $failures[] = $q; continue; } // Throttle according to processing rate. if ($this->rate > 0) { usleep(1000000/$this->rate); } } if (is_callable($callback)) { $callback($success, $failures, $skipped); } return true; }
php
public function processQueue(callable $callback = null) { $queued = $this->loadQueueItems(); if (!is_callable($callback)) { $callback = $this->processedCallback; } $success = []; $failures = []; $skipped = []; foreach ($queued as $q) { try { $res = $q->process($this->itemCallback, $this->itemSuccessCallback, $this->itemFailureCallback); if ($res === true) { $success[] = $q; } elseif ($res === false) { $failures[] = $q; } else { $skipped[] = $q; } } catch (Exception $e) { $this->logger->error( sprintf('Could not process a queue item: %s', $e->getMessage()) ); $failures[] = $q; continue; } // Throttle according to processing rate. if ($this->rate > 0) { usleep(1000000/$this->rate); } } if (is_callable($callback)) { $callback($success, $failures, $skipped); } return true; }
[ "public", "function", "processQueue", "(", "callable", "$", "callback", "=", "null", ")", "{", "$", "queued", "=", "$", "this", "->", "loadQueueItems", "(", ")", ";", "if", "(", "!", "is_callable", "(", "$", "callback", ")", ")", "{", "$", "callback", "=", "$", "this", "->", "processedCallback", ";", "}", "$", "success", "=", "[", "]", ";", "$", "failures", "=", "[", "]", ";", "$", "skipped", "=", "[", "]", ";", "foreach", "(", "$", "queued", "as", "$", "q", ")", "{", "try", "{", "$", "res", "=", "$", "q", "->", "process", "(", "$", "this", "->", "itemCallback", ",", "$", "this", "->", "itemSuccessCallback", ",", "$", "this", "->", "itemFailureCallback", ")", ";", "if", "(", "$", "res", "===", "true", ")", "{", "$", "success", "[", "]", "=", "$", "q", ";", "}", "elseif", "(", "$", "res", "===", "false", ")", "{", "$", "failures", "[", "]", "=", "$", "q", ";", "}", "else", "{", "$", "skipped", "[", "]", "=", "$", "q", ";", "}", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "this", "->", "logger", "->", "error", "(", "sprintf", "(", "'Could not process a queue item: %s'", ",", "$", "e", "->", "getMessage", "(", ")", ")", ")", ";", "$", "failures", "[", "]", "=", "$", "q", ";", "continue", ";", "}", "// Throttle according to processing rate.", "if", "(", "$", "this", "->", "rate", ">", "0", ")", "{", "usleep", "(", "1000000", "/", "$", "this", "->", "rate", ")", ";", "}", "}", "if", "(", "is_callable", "(", "$", "callback", ")", ")", "{", "$", "callback", "(", "$", "success", ",", "$", "failures", ",", "$", "skipped", ")", ";", "}", "return", "true", ";", "}" ]
Process the items of the queue. If no callback is passed and a self::$processedCallback is set, the latter is used. @param callable $callback An optional alternative callback routine executed after all queue items are processed. @return boolean Success / Failure
[ "Process", "the", "items", "of", "the", "queue", "." ]
90c47581cd35fbb554eca513f909171a70325b44
https://github.com/locomotivemtl/charcoal-queue/blob/90c47581cd35fbb554eca513f909171a70325b44/src/Charcoal/Queue/AbstractQueueManager.php#L257-L297
25,354
locomotivemtl/charcoal-queue
src/Charcoal/Queue/AbstractQueueManager.php
AbstractQueueManager.loadQueueItems
public function loadQueueItems() { $loader = new CollectionLoader([ 'logger' => $this->logger, 'factory' => $this->queueItemFactory(), ]); $loader->setModel($this->queueItemProto()); $loader->addFilter([ 'property' => 'processed', 'value' => 0, ]); $loader->addFilter([ 'property' => 'processing_date', 'operator' => '<', 'value' => date('Y-m-d H:i:s'), ]); $queueId = $this->queueId(); if ($queueId) { $loader->addFilter([ 'property' => 'queue_id', 'value' => $queueId, ]); } $loader->addOrder([ 'property' => 'queued_date', 'mode' => 'asc', ]); if ($this->limit > 0) { $loader->setNumPerPage($this->limit); $loader->setPage(0); } $queued = $loader->load(); return $queued; }
php
public function loadQueueItems() { $loader = new CollectionLoader([ 'logger' => $this->logger, 'factory' => $this->queueItemFactory(), ]); $loader->setModel($this->queueItemProto()); $loader->addFilter([ 'property' => 'processed', 'value' => 0, ]); $loader->addFilter([ 'property' => 'processing_date', 'operator' => '<', 'value' => date('Y-m-d H:i:s'), ]); $queueId = $this->queueId(); if ($queueId) { $loader->addFilter([ 'property' => 'queue_id', 'value' => $queueId, ]); } $loader->addOrder([ 'property' => 'queued_date', 'mode' => 'asc', ]); if ($this->limit > 0) { $loader->setNumPerPage($this->limit); $loader->setPage(0); } $queued = $loader->load(); return $queued; }
[ "public", "function", "loadQueueItems", "(", ")", "{", "$", "loader", "=", "new", "CollectionLoader", "(", "[", "'logger'", "=>", "$", "this", "->", "logger", ",", "'factory'", "=>", "$", "this", "->", "queueItemFactory", "(", ")", ",", "]", ")", ";", "$", "loader", "->", "setModel", "(", "$", "this", "->", "queueItemProto", "(", ")", ")", ";", "$", "loader", "->", "addFilter", "(", "[", "'property'", "=>", "'processed'", ",", "'value'", "=>", "0", ",", "]", ")", ";", "$", "loader", "->", "addFilter", "(", "[", "'property'", "=>", "'processing_date'", ",", "'operator'", "=>", "'<'", ",", "'value'", "=>", "date", "(", "'Y-m-d H:i:s'", ")", ",", "]", ")", ";", "$", "queueId", "=", "$", "this", "->", "queueId", "(", ")", ";", "if", "(", "$", "queueId", ")", "{", "$", "loader", "->", "addFilter", "(", "[", "'property'", "=>", "'queue_id'", ",", "'value'", "=>", "$", "queueId", ",", "]", ")", ";", "}", "$", "loader", "->", "addOrder", "(", "[", "'property'", "=>", "'queued_date'", ",", "'mode'", "=>", "'asc'", ",", "]", ")", ";", "if", "(", "$", "this", "->", "limit", ">", "0", ")", "{", "$", "loader", "->", "setNumPerPage", "(", "$", "this", "->", "limit", ")", ";", "$", "loader", "->", "setPage", "(", "0", ")", ";", "}", "$", "queued", "=", "$", "loader", "->", "load", "(", ")", ";", "return", "$", "queued", ";", "}" ]
Retrieve the items of the current queue. @return \Charcoal\Model\Collection|array
[ "Retrieve", "the", "items", "of", "the", "current", "queue", "." ]
90c47581cd35fbb554eca513f909171a70325b44
https://github.com/locomotivemtl/charcoal-queue/blob/90c47581cd35fbb554eca513f909171a70325b44/src/Charcoal/Queue/AbstractQueueManager.php#L304-L342
25,355
Subscribo/klarna-invoice-sdk-wrapped
src/klarnaaddr.php
KlarnaAddr.setEmail
public function setEmail($email) { if (!is_string($email)) { $email = strval($email); } $this->email = $email; }
php
public function setEmail($email) { if (!is_string($email)) { $email = strval($email); } $this->email = $email; }
[ "public", "function", "setEmail", "(", "$", "email", ")", "{", "if", "(", "!", "is_string", "(", "$", "email", ")", ")", "{", "$", "email", "=", "strval", "(", "$", "email", ")", ";", "}", "$", "this", "->", "email", "=", "$", "email", ";", "}" ]
Sets the email address. @param string $email email address @return void
[ "Sets", "the", "email", "address", "." ]
4a45ddd9ec444f5a6d02628ad65e635a3e12611c
https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/klarnaaddr.php#L231-L238
25,356
Subscribo/klarna-invoice-sdk-wrapped
src/klarnaaddr.php
KlarnaAddr.setTelno
public function setTelno($telno) { if (!is_string($telno)) { $telno = strval($telno); } $this->telno = $telno; }
php
public function setTelno($telno) { if (!is_string($telno)) { $telno = strval($telno); } $this->telno = $telno; }
[ "public", "function", "setTelno", "(", "$", "telno", ")", "{", "if", "(", "!", "is_string", "(", "$", "telno", ")", ")", "{", "$", "telno", "=", "strval", "(", "$", "telno", ")", ";", "}", "$", "this", "->", "telno", "=", "$", "telno", ";", "}" ]
Sets the phone number. @param string $telno telno @return void
[ "Sets", "the", "phone", "number", "." ]
4a45ddd9ec444f5a6d02628ad65e635a3e12611c
https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/klarnaaddr.php#L257-L263
25,357
Subscribo/klarna-invoice-sdk-wrapped
src/klarnaaddr.php
KlarnaAddr.setCellno
public function setCellno($cellno) { if (!is_string($cellno)) { $cellno = strval($cellno); } $this->cellno = $cellno; }
php
public function setCellno($cellno) { if (!is_string($cellno)) { $cellno = strval($cellno); } $this->cellno = $cellno; }
[ "public", "function", "setCellno", "(", "$", "cellno", ")", "{", "if", "(", "!", "is_string", "(", "$", "cellno", ")", ")", "{", "$", "cellno", "=", "strval", "(", "$", "cellno", ")", ";", "}", "$", "this", "->", "cellno", "=", "$", "cellno", ";", "}" ]
Sets the cellphone number. @param string $cellno mobile number @return void
[ "Sets", "the", "cellphone", "number", "." ]
4a45ddd9ec444f5a6d02628ad65e635a3e12611c
https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/klarnaaddr.php#L282-L289
25,358
Subscribo/klarna-invoice-sdk-wrapped
src/klarnaaddr.php
KlarnaAddr.setFirstName
public function setFirstName($fname) { if (!is_string($fname)) { $fname = strval($fname); } $this->fname = $fname; }
php
public function setFirstName($fname) { if (!is_string($fname)) { $fname = strval($fname); } $this->fname = $fname; }
[ "public", "function", "setFirstName", "(", "$", "fname", ")", "{", "if", "(", "!", "is_string", "(", "$", "fname", ")", ")", "{", "$", "fname", "=", "strval", "(", "$", "fname", ")", ";", "}", "$", "this", "->", "fname", "=", "$", "fname", ";", "}" ]
Sets the first name. @param string $fname firstname @return void
[ "Sets", "the", "first", "name", "." ]
4a45ddd9ec444f5a6d02628ad65e635a3e12611c
https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/klarnaaddr.php#L308-L315
25,359
Subscribo/klarna-invoice-sdk-wrapped
src/klarnaaddr.php
KlarnaAddr.setLastName
public function setLastName($lname) { if (!is_string($lname)) { $lname = strval($lname); } $this->lname = $lname; }
php
public function setLastName($lname) { if (!is_string($lname)) { $lname = strval($lname); } $this->lname = $lname; }
[ "public", "function", "setLastName", "(", "$", "lname", ")", "{", "if", "(", "!", "is_string", "(", "$", "lname", ")", ")", "{", "$", "lname", "=", "strval", "(", "$", "lname", ")", ";", "}", "$", "this", "->", "lname", "=", "$", "lname", ";", "}" ]
Sets the last name. @param string $lname lastname @return void
[ "Sets", "the", "last", "name", "." ]
4a45ddd9ec444f5a6d02628ad65e635a3e12611c
https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/klarnaaddr.php#L334-L341
25,360
Subscribo/klarna-invoice-sdk-wrapped
src/klarnaaddr.php
KlarnaAddr.setStreet
public function setStreet($street) { if (!is_string($street)) { $street = strval($street); } $this->street = $street; }
php
public function setStreet($street) { if (!is_string($street)) { $street = strval($street); } $this->street = $street; }
[ "public", "function", "setStreet", "(", "$", "street", ")", "{", "if", "(", "!", "is_string", "(", "$", "street", ")", ")", "{", "$", "street", "=", "strval", "(", "$", "street", ")", ";", "}", "$", "this", "->", "street", "=", "$", "street", ";", "}" ]
Sets the street address. @param string $street street address @return void
[ "Sets", "the", "street", "address", "." ]
4a45ddd9ec444f5a6d02628ad65e635a3e12611c
https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/klarnaaddr.php#L416-L423
25,361
Subscribo/klarna-invoice-sdk-wrapped
src/klarnaaddr.php
KlarnaAddr.setZipCode
public function setZipCode($zip) { if (!is_string($zip)) { $zip = strval($zip); } $zip = str_replace(' ', '', $zip); //remove spaces $this->zip = $zip; }
php
public function setZipCode($zip) { if (!is_string($zip)) { $zip = strval($zip); } $zip = str_replace(' ', '', $zip); //remove spaces $this->zip = $zip; }
[ "public", "function", "setZipCode", "(", "$", "zip", ")", "{", "if", "(", "!", "is_string", "(", "$", "zip", ")", ")", "{", "$", "zip", "=", "strval", "(", "$", "zip", ")", ";", "}", "$", "zip", "=", "str_replace", "(", "' '", ",", "''", ",", "$", "zip", ")", ";", "//remove spaces", "$", "this", "->", "zip", "=", "$", "zip", ";", "}" ]
Sets the zip code. @param string $zip zip code @return void
[ "Sets", "the", "zip", "code", "." ]
4a45ddd9ec444f5a6d02628ad65e635a3e12611c
https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/klarnaaddr.php#L442-L452
25,362
Subscribo/klarna-invoice-sdk-wrapped
src/klarnaaddr.php
KlarnaAddr.setCity
public function setCity($city) { if (!is_string($city)) { $city = strval($city); } $this->city = $city; }
php
public function setCity($city) { if (!is_string($city)) { $city = strval($city); } $this->city = $city; }
[ "public", "function", "setCity", "(", "$", "city", ")", "{", "if", "(", "!", "is_string", "(", "$", "city", ")", ")", "{", "$", "city", "=", "strval", "(", "$", "city", ")", ";", "}", "$", "this", "->", "city", "=", "$", "city", ";", "}" ]
Sets the city. @param string $city city @return void
[ "Sets", "the", "city", "." ]
4a45ddd9ec444f5a6d02628ad65e635a3e12611c
https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/klarnaaddr.php#L471-L478
25,363
Subscribo/klarna-invoice-sdk-wrapped
src/klarnaaddr.php
KlarnaAddr.setCountry
public function setCountry($country) { if ($country === null) { throw new Klarna_ArgumentNotSetException('Country'); } if (is_numeric($country)) { if (!is_int($country)) { $country = intval($country); } $this->country = $country; return; } if (strlen($country) == 2 || strlen($country) == 3) { $this->setCountry(KlarnaCountry::fromCode($country)); return; } throw new KlarnaException("Failed to set country! ($country)"); }
php
public function setCountry($country) { if ($country === null) { throw new Klarna_ArgumentNotSetException('Country'); } if (is_numeric($country)) { if (!is_int($country)) { $country = intval($country); } $this->country = $country; return; } if (strlen($country) == 2 || strlen($country) == 3) { $this->setCountry(KlarnaCountry::fromCode($country)); return; } throw new KlarnaException("Failed to set country! ($country)"); }
[ "public", "function", "setCountry", "(", "$", "country", ")", "{", "if", "(", "$", "country", "===", "null", ")", "{", "throw", "new", "Klarna_ArgumentNotSetException", "(", "'Country'", ")", ";", "}", "if", "(", "is_numeric", "(", "$", "country", ")", ")", "{", "if", "(", "!", "is_int", "(", "$", "country", ")", ")", "{", "$", "country", "=", "intval", "(", "$", "country", ")", ";", "}", "$", "this", "->", "country", "=", "$", "country", ";", "return", ";", "}", "if", "(", "strlen", "(", "$", "country", ")", "==", "2", "||", "strlen", "(", "$", "country", ")", "==", "3", ")", "{", "$", "this", "->", "setCountry", "(", "KlarnaCountry", "::", "fromCode", "(", "$", "country", ")", ")", ";", "return", ";", "}", "throw", "new", "KlarnaException", "(", "\"Failed to set country! ($country)\"", ")", ";", "}" ]
Sets the country, use either a two letter representation or the integer constant. @param int $country {@link KlarnaCountry} @throws KlarnaException @return void
[ "Sets", "the", "country", "use", "either", "a", "two", "letter", "representation", "or", "the", "integer", "constant", "." ]
4a45ddd9ec444f5a6d02628ad65e635a3e12611c
https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/klarnaaddr.php#L510-L527
25,364
Subscribo/klarna-invoice-sdk-wrapped
src/klarnaaddr.php
KlarnaAddr.toArray
public function toArray() { return array( 'email' => $this->getEmail(), 'telno' => $this->getTelno(), 'cellno' => $this->getCellno(), 'fname' => $this->getFirstName(), 'lname' => $this->getLastName(), 'company' => $this->getCompanyName(), 'careof' => $this->getCareof(), 'street' => $this->getStreet(), 'house_number' => $this->getHouseNumber(), 'house_extension' => $this->getHouseExt(), 'zip' => $this->getZipCode(), 'city' => $this->getCity(), 'country' => $this->getCountry(), ); }
php
public function toArray() { return array( 'email' => $this->getEmail(), 'telno' => $this->getTelno(), 'cellno' => $this->getCellno(), 'fname' => $this->getFirstName(), 'lname' => $this->getLastName(), 'company' => $this->getCompanyName(), 'careof' => $this->getCareof(), 'street' => $this->getStreet(), 'house_number' => $this->getHouseNumber(), 'house_extension' => $this->getHouseExt(), 'zip' => $this->getZipCode(), 'city' => $this->getCity(), 'country' => $this->getCountry(), ); }
[ "public", "function", "toArray", "(", ")", "{", "return", "array", "(", "'email'", "=>", "$", "this", "->", "getEmail", "(", ")", ",", "'telno'", "=>", "$", "this", "->", "getTelno", "(", ")", ",", "'cellno'", "=>", "$", "this", "->", "getCellno", "(", ")", ",", "'fname'", "=>", "$", "this", "->", "getFirstName", "(", ")", ",", "'lname'", "=>", "$", "this", "->", "getLastName", "(", ")", ",", "'company'", "=>", "$", "this", "->", "getCompanyName", "(", ")", ",", "'careof'", "=>", "$", "this", "->", "getCareof", "(", ")", ",", "'street'", "=>", "$", "this", "->", "getStreet", "(", ")", ",", "'house_number'", "=>", "$", "this", "->", "getHouseNumber", "(", ")", ",", "'house_extension'", "=>", "$", "this", "->", "getHouseExt", "(", ")", ",", "'zip'", "=>", "$", "this", "->", "getZipCode", "(", ")", ",", "'city'", "=>", "$", "this", "->", "getCity", "(", ")", ",", "'country'", "=>", "$", "this", "->", "getCountry", "(", ")", ",", ")", ";", "}" ]
Returns an associative array representing this object. @return array
[ "Returns", "an", "associative", "array", "representing", "this", "object", "." ]
4a45ddd9ec444f5a6d02628ad65e635a3e12611c
https://github.com/Subscribo/klarna-invoice-sdk-wrapped/blob/4a45ddd9ec444f5a6d02628ad65e635a3e12611c/src/klarnaaddr.php#L590-L607
25,365
Talis90/HtmlMediaFinder
library/HtmlMediaFinder/RemoteXpathAdapter.php
RemoteXpathAdapter.postRequest
static function postRequest($url, array $post) { $handle = curl_init($url); curl_setopt_array($handle, [ CURLOPT_POST => count($post), CURLOPT_POSTFIELDS => http_build_query($post), CURLOPT_RETURNTRANSFER => 1 ]); $result = curl_exec($handle); curl_close($handle); return $result; }
php
static function postRequest($url, array $post) { $handle = curl_init($url); curl_setopt_array($handle, [ CURLOPT_POST => count($post), CURLOPT_POSTFIELDS => http_build_query($post), CURLOPT_RETURNTRANSFER => 1 ]); $result = curl_exec($handle); curl_close($handle); return $result; }
[ "static", "function", "postRequest", "(", "$", "url", ",", "array", "$", "post", ")", "{", "$", "handle", "=", "curl_init", "(", "$", "url", ")", ";", "curl_setopt_array", "(", "$", "handle", ",", "[", "CURLOPT_POST", "=>", "count", "(", "$", "post", ")", ",", "CURLOPT_POSTFIELDS", "=>", "http_build_query", "(", "$", "post", ")", ",", "CURLOPT_RETURNTRANSFER", "=>", "1", "]", ")", ";", "$", "result", "=", "curl_exec", "(", "$", "handle", ")", ";", "curl_close", "(", "$", "handle", ")", ";", "return", "$", "result", ";", "}" ]
Get result string of post request @param string $url @param array $post @return string
[ "Get", "result", "string", "of", "post", "request" ]
fd19212a88d5d3f78d20aeea1accf7be427643b0
https://github.com/Talis90/HtmlMediaFinder/blob/fd19212a88d5d3f78d20aeea1accf7be427643b0/library/HtmlMediaFinder/RemoteXpathAdapter.php#L42-L55
25,366
koolkode/meta
src/Source/SourceParser.php
SourceParser.parse
public function parse(SourceStream $code, SourceStorageInterface $storage = NULL) { $buffer = new SourceBuffer(); $this->doParse($code, $buffer, $storage); return $buffer; }
php
public function parse(SourceStream $code, SourceStorageInterface $storage = NULL) { $buffer = new SourceBuffer(); $this->doParse($code, $buffer, $storage); return $buffer; }
[ "public", "function", "parse", "(", "SourceStream", "$", "code", ",", "SourceStorageInterface", "$", "storage", "=", "NULL", ")", "{", "$", "buffer", "=", "new", "SourceBuffer", "(", ")", ";", "$", "this", "->", "doParse", "(", "$", "code", ",", "$", "buffer", ",", "$", "storage", ")", ";", "return", "$", "buffer", ";", "}" ]
Parse the given code and create a SourceGenerator from it, extracted data for static analysis is stored in the given storage implementation. @param SourceStream $code The source code to be parsed. @param SourceStorageInterface $storage The stoage implementation for extracted data. @return SourceGenerator
[ "Parse", "the", "given", "code", "and", "create", "a", "SourceGenerator", "from", "it", "extracted", "data", "for", "static", "analysis", "is", "stored", "in", "the", "given", "storage", "implementation", "." ]
339db24d3ce461190f552c96e243bca21010f360
https://github.com/koolkode/meta/blob/339db24d3ce461190f552c96e243bca21010f360/src/Source/SourceParser.php#L40-L46
25,367
koolkode/meta
src/Source/SourceParser.php
SourceParser.lookup
protected function lookup($localName, $namespace = '', array $import = []) { if($localName == '') { return $localName; } switch(strtolower($localName)) { case 'bool': case 'int': case 'float': case 'string': case 'array': case 'callable': return strtolower($localName); break; } if($localName[0] == '\\') { return ltrim($localName, '\\'); } if(false === (strpos($localName, '\\'))) { $n = strtolower($localName); return isset($import[$n]) ? $import[$n] : ltrim($namespace . '\\' . $localName, '\\'); } $parts = explode('\\', $localName, 2); $alias = strtolower($parts[0]); if(isset($import[$alias])) { return ltrim($import[$alias] . '\\' . $parts[1], '\\'); } return ltrim($namespace . '\\' . $localName, '\\'); }
php
protected function lookup($localName, $namespace = '', array $import = []) { if($localName == '') { return $localName; } switch(strtolower($localName)) { case 'bool': case 'int': case 'float': case 'string': case 'array': case 'callable': return strtolower($localName); break; } if($localName[0] == '\\') { return ltrim($localName, '\\'); } if(false === (strpos($localName, '\\'))) { $n = strtolower($localName); return isset($import[$n]) ? $import[$n] : ltrim($namespace . '\\' . $localName, '\\'); } $parts = explode('\\', $localName, 2); $alias = strtolower($parts[0]); if(isset($import[$alias])) { return ltrim($import[$alias] . '\\' . $parts[1], '\\'); } return ltrim($namespace . '\\' . $localName, '\\'); }
[ "protected", "function", "lookup", "(", "$", "localName", ",", "$", "namespace", "=", "''", ",", "array", "$", "import", "=", "[", "]", ")", "{", "if", "(", "$", "localName", "==", "''", ")", "{", "return", "$", "localName", ";", "}", "switch", "(", "strtolower", "(", "$", "localName", ")", ")", "{", "case", "'bool'", ":", "case", "'int'", ":", "case", "'float'", ":", "case", "'string'", ":", "case", "'array'", ":", "case", "'callable'", ":", "return", "strtolower", "(", "$", "localName", ")", ";", "break", ";", "}", "if", "(", "$", "localName", "[", "0", "]", "==", "'\\\\'", ")", "{", "return", "ltrim", "(", "$", "localName", ",", "'\\\\'", ")", ";", "}", "if", "(", "false", "===", "(", "strpos", "(", "$", "localName", ",", "'\\\\'", ")", ")", ")", "{", "$", "n", "=", "strtolower", "(", "$", "localName", ")", ";", "return", "isset", "(", "$", "import", "[", "$", "n", "]", ")", "?", "$", "import", "[", "$", "n", "]", ":", "ltrim", "(", "$", "namespace", ".", "'\\\\'", ".", "$", "localName", ",", "'\\\\'", ")", ";", "}", "$", "parts", "=", "explode", "(", "'\\\\'", ",", "$", "localName", ",", "2", ")", ";", "$", "alias", "=", "strtolower", "(", "$", "parts", "[", "0", "]", ")", ";", "if", "(", "isset", "(", "$", "import", "[", "$", "alias", "]", ")", ")", "{", "return", "ltrim", "(", "$", "import", "[", "$", "alias", "]", ".", "'\\\\'", ".", "$", "parts", "[", "1", "]", ",", "'\\\\'", ")", ";", "}", "return", "ltrim", "(", "$", "namespace", ".", "'\\\\'", ".", "$", "localName", ",", "'\\\\'", ")", ";", "}" ]
Lookup a fully qualified name in the given namespace considering imports. @param string $localName @param string $namespace @param array<string, string> $import @return string
[ "Lookup", "a", "fully", "qualified", "name", "in", "the", "given", "namespace", "considering", "imports", "." ]
339db24d3ce461190f552c96e243bca21010f360
https://github.com/koolkode/meta/blob/339db24d3ce461190f552c96e243bca21010f360/src/Source/SourceParser.php#L638-L678
25,368
koolkode/meta
src/Source/SourceParser.php
SourceParser.parseTypeModifiers
protected function parseTypeModifiers(array $tokens) { $modifiers = 0; foreach($tokens as $tok) { if(is_array($tok)) { switch($tok[0]) { case T_ABSTRACT: $modifiers |= MetaInfo::IS_ABSTRACT; break; case T_FINAL: $modifiers |= MetaInfo::IS_FINAL; break; } } } return $modifiers; }
php
protected function parseTypeModifiers(array $tokens) { $modifiers = 0; foreach($tokens as $tok) { if(is_array($tok)) { switch($tok[0]) { case T_ABSTRACT: $modifiers |= MetaInfo::IS_ABSTRACT; break; case T_FINAL: $modifiers |= MetaInfo::IS_FINAL; break; } } } return $modifiers; }
[ "protected", "function", "parseTypeModifiers", "(", "array", "$", "tokens", ")", "{", "$", "modifiers", "=", "0", ";", "foreach", "(", "$", "tokens", "as", "$", "tok", ")", "{", "if", "(", "is_array", "(", "$", "tok", ")", ")", "{", "switch", "(", "$", "tok", "[", "0", "]", ")", "{", "case", "T_ABSTRACT", ":", "$", "modifiers", "|=", "MetaInfo", "::", "IS_ABSTRACT", ";", "break", ";", "case", "T_FINAL", ":", "$", "modifiers", "|=", "MetaInfo", "::", "IS_FINAL", ";", "break", ";", "}", "}", "}", "return", "$", "modifiers", ";", "}" ]
Extract all type modifiers from the given tokens and combine them into a bit mask. @param array $tokens @return integer
[ "Extract", "all", "type", "modifiers", "from", "the", "given", "tokens", "and", "combine", "them", "into", "a", "bit", "mask", "." ]
339db24d3ce461190f552c96e243bca21010f360
https://github.com/koolkode/meta/blob/339db24d3ce461190f552c96e243bca21010f360/src/Source/SourceParser.php#L686-L707
25,369
koolkode/meta
src/Source/SourceParser.php
SourceParser.parseFieldModifiers
protected function parseFieldModifiers(array $tokens) { $modifiers = MetaInfo::IS_PUBLIC; foreach($tokens as $tok) { if(is_array($tok)) { switch($tok[0]) { case T_VAR: case T_PUBLIC: $modifiers = ($modifiers | MetaInfo::MASK_VISIBILITY) ^ MetaInfo::IS_NOT_PUBLIC; break; case T_PRIVATE: $modifiers = ($modifiers | MetaInfo::MASK_VISIBILITY) ^ MetaInfo::IS_NOT_PRIVATE; break; case T_PROTECTED: $modifiers = ($modifiers | MetaInfo::MASK_VISIBILITY) ^ MetaInfo::IS_NOT_PROTECTED; break; case T_STATIC: $modifiers |= MetaInfo::IS_STATIC; break; } } } return $modifiers; }
php
protected function parseFieldModifiers(array $tokens) { $modifiers = MetaInfo::IS_PUBLIC; foreach($tokens as $tok) { if(is_array($tok)) { switch($tok[0]) { case T_VAR: case T_PUBLIC: $modifiers = ($modifiers | MetaInfo::MASK_VISIBILITY) ^ MetaInfo::IS_NOT_PUBLIC; break; case T_PRIVATE: $modifiers = ($modifiers | MetaInfo::MASK_VISIBILITY) ^ MetaInfo::IS_NOT_PRIVATE; break; case T_PROTECTED: $modifiers = ($modifiers | MetaInfo::MASK_VISIBILITY) ^ MetaInfo::IS_NOT_PROTECTED; break; case T_STATIC: $modifiers |= MetaInfo::IS_STATIC; break; } } } return $modifiers; }
[ "protected", "function", "parseFieldModifiers", "(", "array", "$", "tokens", ")", "{", "$", "modifiers", "=", "MetaInfo", "::", "IS_PUBLIC", ";", "foreach", "(", "$", "tokens", "as", "$", "tok", ")", "{", "if", "(", "is_array", "(", "$", "tok", ")", ")", "{", "switch", "(", "$", "tok", "[", "0", "]", ")", "{", "case", "T_VAR", ":", "case", "T_PUBLIC", ":", "$", "modifiers", "=", "(", "$", "modifiers", "|", "MetaInfo", "::", "MASK_VISIBILITY", ")", "^", "MetaInfo", "::", "IS_NOT_PUBLIC", ";", "break", ";", "case", "T_PRIVATE", ":", "$", "modifiers", "=", "(", "$", "modifiers", "|", "MetaInfo", "::", "MASK_VISIBILITY", ")", "^", "MetaInfo", "::", "IS_NOT_PRIVATE", ";", "break", ";", "case", "T_PROTECTED", ":", "$", "modifiers", "=", "(", "$", "modifiers", "|", "MetaInfo", "::", "MASK_VISIBILITY", ")", "^", "MetaInfo", "::", "IS_NOT_PROTECTED", ";", "break", ";", "case", "T_STATIC", ":", "$", "modifiers", "|=", "MetaInfo", "::", "IS_STATIC", ";", "break", ";", "}", "}", "}", "return", "$", "modifiers", ";", "}" ]
Parse all field modifiers from the given tokens and combine them into a bit mask. @param array $tokens @return integer
[ "Parse", "all", "field", "modifiers", "from", "the", "given", "tokens", "and", "combine", "them", "into", "a", "bit", "mask", "." ]
339db24d3ce461190f552c96e243bca21010f360
https://github.com/koolkode/meta/blob/339db24d3ce461190f552c96e243bca21010f360/src/Source/SourceParser.php#L715-L743
25,370
koolkode/meta
src/Source/SourceParser.php
SourceParser.parseMethodModifiers
protected function parseMethodModifiers(array $tokens) { $modifiers = MetaInfo::IS_PUBLIC; foreach($tokens as $tok) { if(is_array($tok)) { switch($tok[0]) { case T_PUBLIC: $modifiers = ($modifiers | MetaInfo::MASK_VISIBILITY) ^ MetaInfo::IS_NOT_PUBLIC; break; case T_PRIVATE: $modifiers = ($modifiers | MetaInfo::MASK_VISIBILITY) ^ MetaInfo::IS_NOT_PRIVATE; break; case T_PROTECTED: $modifiers = ($modifiers | MetaInfo::MASK_VISIBILITY) ^ MetaInfo::IS_NOT_PROTECTED; break; case T_STATIC: $modifiers |= MetaInfo::IS_STATIC; break; case T_ABSTRACT: $modifiers |= MetaInfo::IS_ABSTRACT; break; case T_FINAL: $modifiers |= MetaInfo::IS_FINAL; break; } } } return $modifiers; }
php
protected function parseMethodModifiers(array $tokens) { $modifiers = MetaInfo::IS_PUBLIC; foreach($tokens as $tok) { if(is_array($tok)) { switch($tok[0]) { case T_PUBLIC: $modifiers = ($modifiers | MetaInfo::MASK_VISIBILITY) ^ MetaInfo::IS_NOT_PUBLIC; break; case T_PRIVATE: $modifiers = ($modifiers | MetaInfo::MASK_VISIBILITY) ^ MetaInfo::IS_NOT_PRIVATE; break; case T_PROTECTED: $modifiers = ($modifiers | MetaInfo::MASK_VISIBILITY) ^ MetaInfo::IS_NOT_PROTECTED; break; case T_STATIC: $modifiers |= MetaInfo::IS_STATIC; break; case T_ABSTRACT: $modifiers |= MetaInfo::IS_ABSTRACT; break; case T_FINAL: $modifiers |= MetaInfo::IS_FINAL; break; } } } return $modifiers; }
[ "protected", "function", "parseMethodModifiers", "(", "array", "$", "tokens", ")", "{", "$", "modifiers", "=", "MetaInfo", "::", "IS_PUBLIC", ";", "foreach", "(", "$", "tokens", "as", "$", "tok", ")", "{", "if", "(", "is_array", "(", "$", "tok", ")", ")", "{", "switch", "(", "$", "tok", "[", "0", "]", ")", "{", "case", "T_PUBLIC", ":", "$", "modifiers", "=", "(", "$", "modifiers", "|", "MetaInfo", "::", "MASK_VISIBILITY", ")", "^", "MetaInfo", "::", "IS_NOT_PUBLIC", ";", "break", ";", "case", "T_PRIVATE", ":", "$", "modifiers", "=", "(", "$", "modifiers", "|", "MetaInfo", "::", "MASK_VISIBILITY", ")", "^", "MetaInfo", "::", "IS_NOT_PRIVATE", ";", "break", ";", "case", "T_PROTECTED", ":", "$", "modifiers", "=", "(", "$", "modifiers", "|", "MetaInfo", "::", "MASK_VISIBILITY", ")", "^", "MetaInfo", "::", "IS_NOT_PROTECTED", ";", "break", ";", "case", "T_STATIC", ":", "$", "modifiers", "|=", "MetaInfo", "::", "IS_STATIC", ";", "break", ";", "case", "T_ABSTRACT", ":", "$", "modifiers", "|=", "MetaInfo", "::", "IS_ABSTRACT", ";", "break", ";", "case", "T_FINAL", ":", "$", "modifiers", "|=", "MetaInfo", "::", "IS_FINAL", ";", "break", ";", "}", "}", "}", "return", "$", "modifiers", ";", "}" ]
Parse all method modifiers from the given tokens and combine them into a bit mask. @param array $tokens @return integer
[ "Parse", "all", "method", "modifiers", "from", "the", "given", "tokens", "and", "combine", "them", "into", "a", "bit", "mask", "." ]
339db24d3ce461190f552c96e243bca21010f360
https://github.com/koolkode/meta/blob/339db24d3ce461190f552c96e243bca21010f360/src/Source/SourceParser.php#L751-L784
25,371
phossa/phossa-shared
src/Phossa/Shared/Message/MessageAbstract.php
MessageAbstract.buildMessage
protected static function buildMessage( /*# string */ $template, array $arguments )/*# : string */ { // use formatter if (self::hasFormatter()) { return self::getFormatter() ->formatMessage($template, $arguments); // default is vsprintf() } else { // make sure arguments are all strings array_walk($arguments, function (&$value) { $value = is_scalar($value) ? (string) $value : substr(print_r($value, true), 0, 50); }); // make sure '%s' count in $template is same as size of $arguments $count = substr_count($template, '%s'); $size = sizeof($arguments); if ($count > $size) { $arguments = $arguments + array_fill($size, $count - $size, ''); } else { $template .= str_repeat(' %s', $size - $count); } return vsprintf($template, $arguments); } }
php
protected static function buildMessage( /*# string */ $template, array $arguments )/*# : string */ { // use formatter if (self::hasFormatter()) { return self::getFormatter() ->formatMessage($template, $arguments); // default is vsprintf() } else { // make sure arguments are all strings array_walk($arguments, function (&$value) { $value = is_scalar($value) ? (string) $value : substr(print_r($value, true), 0, 50); }); // make sure '%s' count in $template is same as size of $arguments $count = substr_count($template, '%s'); $size = sizeof($arguments); if ($count > $size) { $arguments = $arguments + array_fill($size, $count - $size, ''); } else { $template .= str_repeat(' %s', $size - $count); } return vsprintf($template, $arguments); } }
[ "protected", "static", "function", "buildMessage", "(", "/*# string */", "$", "template", ",", "array", "$", "arguments", ")", "/*# : string */", "{", "// use formatter", "if", "(", "self", "::", "hasFormatter", "(", ")", ")", "{", "return", "self", "::", "getFormatter", "(", ")", "->", "formatMessage", "(", "$", "template", ",", "$", "arguments", ")", ";", "// default is vsprintf()", "}", "else", "{", "// make sure arguments are all strings", "array_walk", "(", "$", "arguments", ",", "function", "(", "&", "$", "value", ")", "{", "$", "value", "=", "is_scalar", "(", "$", "value", ")", "?", "(", "string", ")", "$", "value", ":", "substr", "(", "print_r", "(", "$", "value", ",", "true", ")", ",", "0", ",", "50", ")", ";", "}", ")", ";", "// make sure '%s' count in $template is same as size of $arguments", "$", "count", "=", "substr_count", "(", "$", "template", ",", "'%s'", ")", ";", "$", "size", "=", "sizeof", "(", "$", "arguments", ")", ";", "if", "(", "$", "count", ">", "$", "size", ")", "{", "$", "arguments", "=", "$", "arguments", "+", "array_fill", "(", "$", "size", ",", "$", "count", "-", "$", "size", ",", "''", ")", ";", "}", "else", "{", "$", "template", ".=", "str_repeat", "(", "' %s'", ",", "$", "size", "-", "$", "count", ")", ";", "}", "return", "vsprintf", "(", "$", "template", ",", "$", "arguments", ")", ";", "}", "}" ]
Build message from template and arguments. - Make sure '%s' matches the arguments provided. - Use message formatter if exists @param string $template message template @param array $arguments arguments for the template @return string @access protected @static
[ "Build", "message", "from", "template", "and", "arguments", "." ]
fcf140c09e94c3a441ee4e285de0b4c18cb6504b
https://github.com/phossa/phossa-shared/blob/fcf140c09e94c3a441ee4e285de0b4c18cb6504b/src/Phossa/Shared/Message/MessageAbstract.php#L175-L202
25,372
jonesiscoding/device
src/DeviceFeatureInfo.php
DeviceFeatureInfo.get
public function get( $item = null ) { if( empty( $this->_detect ) || !array_key_exists( $item, $this->_detect ) ) { $this->_detect = $this->detect(); } if( $item ) { return ( array_key_exists( $item, $this->_detect ) ) ? $this->_detect[ $item ] : false; } return $this->_detect; }
php
public function get( $item = null ) { if( empty( $this->_detect ) || !array_key_exists( $item, $this->_detect ) ) { $this->_detect = $this->detect(); } if( $item ) { return ( array_key_exists( $item, $this->_detect ) ) ? $this->_detect[ $item ] : false; } return $this->_detect; }
[ "public", "function", "get", "(", "$", "item", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "_detect", ")", "||", "!", "array_key_exists", "(", "$", "item", ",", "$", "this", "->", "_detect", ")", ")", "{", "$", "this", "->", "_detect", "=", "$", "this", "->", "detect", "(", ")", ";", "}", "if", "(", "$", "item", ")", "{", "return", "(", "array_key_exists", "(", "$", "item", ",", "$", "this", "->", "_detect", ")", ")", "?", "$", "this", "->", "_detect", "[", "$", "item", "]", ":", "false", ";", "}", "return", "$", "this", "->", "_detect", ";", "}" ]
Retrieves the full results of the current client detection, or a specific parameter. Available parameters are hidpi, width, height, speed, modern, touch, and cookies. @param string|null $item The parameter you wish to detect @return string|array|bool The detected parameter, or if $item was not given, the array of all parameters.
[ "Retrieves", "the", "full", "results", "of", "the", "current", "client", "detection", "or", "a", "specific", "parameter", ".", "Available", "parameters", "are", "hidpi", "width", "height", "speed", "modern", "touch", "and", "cookies", "." ]
d3c66f934bcaa8e5e0424cf684c995b1c80cee29
https://github.com/jonesiscoding/device/blob/d3c66f934bcaa8e5e0424cf684c995b1c80cee29/src/DeviceFeatureInfo.php#L49-L62
25,373
jonesiscoding/device
src/DeviceFeatureInfo.php
DeviceFeatureInfo.detect
private function detect() { $detect = array(); $defaults = $this->getDefaults(); if( $this->isDetected() ) { $detect = json_decode( $_COOKIE[ $this->cookieName ], true ); if( !is_null( $detect ) ) { // Convert Boolean values from strings foreach( $detect as $k => $v ) { if( $v === "false" ) { $detect[ $k ] = $v = false; } if( $v === "true" ) { $detect[ $k ] = $v = true; } // Allow Server Overrides if ( $v === false && in_array( $k, DetectDefaults::SERVER ) ) { $detect[$k] = ( array_key_exists( $k, $defaults ) ) ? $defaults[ $k ] : $v; } } } } elseif( !$this->DetectByUserAgent instanceof DetectByUserAgent ) { // Attempt to get from User Agent $this->DetectByUserAgent = new DetectByUserAgent(); $detect = $this->DetectByUserAgent->detect(); } // Append Defaults return ( !empty( $detect ) ) ? array_merge( $defaults, $detect ) : $defaults; }
php
private function detect() { $detect = array(); $defaults = $this->getDefaults(); if( $this->isDetected() ) { $detect = json_decode( $_COOKIE[ $this->cookieName ], true ); if( !is_null( $detect ) ) { // Convert Boolean values from strings foreach( $detect as $k => $v ) { if( $v === "false" ) { $detect[ $k ] = $v = false; } if( $v === "true" ) { $detect[ $k ] = $v = true; } // Allow Server Overrides if ( $v === false && in_array( $k, DetectDefaults::SERVER ) ) { $detect[$k] = ( array_key_exists( $k, $defaults ) ) ? $defaults[ $k ] : $v; } } } } elseif( !$this->DetectByUserAgent instanceof DetectByUserAgent ) { // Attempt to get from User Agent $this->DetectByUserAgent = new DetectByUserAgent(); $detect = $this->DetectByUserAgent->detect(); } // Append Defaults return ( !empty( $detect ) ) ? array_merge( $defaults, $detect ) : $defaults; }
[ "private", "function", "detect", "(", ")", "{", "$", "detect", "=", "array", "(", ")", ";", "$", "defaults", "=", "$", "this", "->", "getDefaults", "(", ")", ";", "if", "(", "$", "this", "->", "isDetected", "(", ")", ")", "{", "$", "detect", "=", "json_decode", "(", "$", "_COOKIE", "[", "$", "this", "->", "cookieName", "]", ",", "true", ")", ";", "if", "(", "!", "is_null", "(", "$", "detect", ")", ")", "{", "// Convert Boolean values from strings", "foreach", "(", "$", "detect", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "$", "v", "===", "\"false\"", ")", "{", "$", "detect", "[", "$", "k", "]", "=", "$", "v", "=", "false", ";", "}", "if", "(", "$", "v", "===", "\"true\"", ")", "{", "$", "detect", "[", "$", "k", "]", "=", "$", "v", "=", "true", ";", "}", "// Allow Server Overrides", "if", "(", "$", "v", "===", "false", "&&", "in_array", "(", "$", "k", ",", "DetectDefaults", "::", "SERVER", ")", ")", "{", "$", "detect", "[", "$", "k", "]", "=", "(", "array_key_exists", "(", "$", "k", ",", "$", "defaults", ")", ")", "?", "$", "defaults", "[", "$", "k", "]", ":", "$", "v", ";", "}", "}", "}", "}", "elseif", "(", "!", "$", "this", "->", "DetectByUserAgent", "instanceof", "DetectByUserAgent", ")", "{", "// Attempt to get from User Agent", "$", "this", "->", "DetectByUserAgent", "=", "new", "DetectByUserAgent", "(", ")", ";", "$", "detect", "=", "$", "this", "->", "DetectByUserAgent", "->", "detect", "(", ")", ";", "}", "// Append Defaults", "return", "(", "!", "empty", "(", "$", "detect", ")", ")", "?", "array_merge", "(", "$", "defaults", ",", "$", "detect", ")", ":", "$", "defaults", ";", "}" ]
Parses the cookie left by d.js. If the cookie is not set due to Javascript being disabled, or cookies being being blocked, DetectByUserAgent is used to determine the values by the user agent. Using the user agent can be quite flawed. As we are limiting it to feature detection, it makes a good backup here. @return array
[ "Parses", "the", "cookie", "left", "by", "d", ".", "js", ".", "If", "the", "cookie", "is", "not", "set", "due", "to", "Javascript", "being", "disabled", "or", "cookies", "being", "being", "blocked", "DetectByUserAgent", "is", "used", "to", "determine", "the", "values", "by", "the", "user", "agent", "." ]
d3c66f934bcaa8e5e0424cf684c995b1c80cee29
https://github.com/jonesiscoding/device/blob/d3c66f934bcaa8e5e0424cf684c995b1c80cee29/src/DeviceFeatureInfo.php#L221-L253
25,374
cubicmushroom/valueobjects
src/DateTime/Date.php
Date.fromNative
public static function fromNative() { $args = func_get_args(); $year = new Year($args[0]); $month = Month::fromNative($args[1]); $day = new MonthDay($args[2]); return new static($year, $month, $day); }
php
public static function fromNative() { $args = func_get_args(); $year = new Year($args[0]); $month = Month::fromNative($args[1]); $day = new MonthDay($args[2]); return new static($year, $month, $day); }
[ "public", "static", "function", "fromNative", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "year", "=", "new", "Year", "(", "$", "args", "[", "0", "]", ")", ";", "$", "month", "=", "Month", "::", "fromNative", "(", "$", "args", "[", "1", "]", ")", ";", "$", "day", "=", "new", "MonthDay", "(", "$", "args", "[", "2", "]", ")", ";", "return", "new", "static", "(", "$", "year", ",", "$", "month", ",", "$", "day", ")", ";", "}" ]
Returns a new Date from native year, month and day values @param int $year @param string $month @param int $day @return Date
[ "Returns", "a", "new", "Date", "from", "native", "year", "month", "and", "day", "values" ]
4554239ab75d65eeb9773219aa5b07e9fbfabb92
https://github.com/cubicmushroom/valueobjects/blob/4554239ab75d65eeb9773219aa5b07e9fbfabb92/src/DateTime/Date.php#L28-L37
25,375
cubicmushroom/valueobjects
src/DateTime/Date.php
Date.fromNativeDateTime
public static function fromNativeDateTime(\DateTime $date) { $year = \intval($date->format('Y')); $month = Month::fromNativeDateTime($date); $day = \intval($date->format('d')); return new static(new Year($year), $month, new MonthDay($day)); }
php
public static function fromNativeDateTime(\DateTime $date) { $year = \intval($date->format('Y')); $month = Month::fromNativeDateTime($date); $day = \intval($date->format('d')); return new static(new Year($year), $month, new MonthDay($day)); }
[ "public", "static", "function", "fromNativeDateTime", "(", "\\", "DateTime", "$", "date", ")", "{", "$", "year", "=", "\\", "intval", "(", "$", "date", "->", "format", "(", "'Y'", ")", ")", ";", "$", "month", "=", "Month", "::", "fromNativeDateTime", "(", "$", "date", ")", ";", "$", "day", "=", "\\", "intval", "(", "$", "date", "->", "format", "(", "'d'", ")", ")", ";", "return", "new", "static", "(", "new", "Year", "(", "$", "year", ")", ",", "$", "month", ",", "new", "MonthDay", "(", "$", "day", ")", ")", ";", "}" ]
Returns a new Date from a native PHP \DateTime @param \DateTime $date @return Date
[ "Returns", "a", "new", "Date", "from", "a", "native", "PHP", "\\", "DateTime" ]
4554239ab75d65eeb9773219aa5b07e9fbfabb92
https://github.com/cubicmushroom/valueobjects/blob/4554239ab75d65eeb9773219aa5b07e9fbfabb92/src/DateTime/Date.php#L45-L52
25,376
cubicmushroom/valueobjects
src/DateTime/Date.php
Date.sameValueAs
public function sameValueAs(ValueObjectInterface $date) { if (false === Util::classEquals($this, $date)) { return false; } return $this->getYear()->sameValueAs($date->getYear()) && $this->getMonth()->sameValueAs($date->getMonth()) && $this->getDay()->sameValueAs($date->getDay()); }
php
public function sameValueAs(ValueObjectInterface $date) { if (false === Util::classEquals($this, $date)) { return false; } return $this->getYear()->sameValueAs($date->getYear()) && $this->getMonth()->sameValueAs($date->getMonth()) && $this->getDay()->sameValueAs($date->getDay()); }
[ "public", "function", "sameValueAs", "(", "ValueObjectInterface", "$", "date", ")", "{", "if", "(", "false", "===", "Util", "::", "classEquals", "(", "$", "this", ",", "$", "date", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "getYear", "(", ")", "->", "sameValueAs", "(", "$", "date", "->", "getYear", "(", ")", ")", "&&", "$", "this", "->", "getMonth", "(", ")", "->", "sameValueAs", "(", "$", "date", "->", "getMonth", "(", ")", ")", "&&", "$", "this", "->", "getDay", "(", ")", "->", "sameValueAs", "(", "$", "date", "->", "getDay", "(", ")", ")", ";", "}" ]
Tells whether two Date are equal by comparing their values @param ValueObjectInterface $date @return bool
[ "Tells", "whether", "two", "Date", "are", "equal", "by", "comparing", "their", "values" ]
4554239ab75d65eeb9773219aa5b07e9fbfabb92
https://github.com/cubicmushroom/valueobjects/blob/4554239ab75d65eeb9773219aa5b07e9fbfabb92/src/DateTime/Date.php#L94-L103
25,377
cubicmushroom/valueobjects
src/DateTime/Date.php
Date.toNativeDateTime
public function toNativeDateTime() { $year = $this->getYear()->toNative(); $month = $this->getMonth()->getNumericValue(); $day = $this->getDay()->toNative(); $date = new \DateTime(); $date->setDate($year, $month, $day); $date->setTime(0, 0, 0); return $date; }
php
public function toNativeDateTime() { $year = $this->getYear()->toNative(); $month = $this->getMonth()->getNumericValue(); $day = $this->getDay()->toNative(); $date = new \DateTime(); $date->setDate($year, $month, $day); $date->setTime(0, 0, 0); return $date; }
[ "public", "function", "toNativeDateTime", "(", ")", "{", "$", "year", "=", "$", "this", "->", "getYear", "(", ")", "->", "toNative", "(", ")", ";", "$", "month", "=", "$", "this", "->", "getMonth", "(", ")", "->", "getNumericValue", "(", ")", ";", "$", "day", "=", "$", "this", "->", "getDay", "(", ")", "->", "toNative", "(", ")", ";", "$", "date", "=", "new", "\\", "DateTime", "(", ")", ";", "$", "date", "->", "setDate", "(", "$", "year", ",", "$", "month", ",", "$", "day", ")", ";", "$", "date", "->", "setTime", "(", "0", ",", "0", ",", "0", ")", ";", "return", "$", "date", ";", "}" ]
Returns a native PHP \DateTime version of the current Date @return \DateTime
[ "Returns", "a", "native", "PHP", "\\", "DateTime", "version", "of", "the", "current", "Date" ]
4554239ab75d65eeb9773219aa5b07e9fbfabb92
https://github.com/cubicmushroom/valueobjects/blob/4554239ab75d65eeb9773219aa5b07e9fbfabb92/src/DateTime/Date.php#L140-L151
25,378
bseddon/XPath20
DOM/DOMXPathNavigator.php
DOMXPathNavigator.ComparePosition
public function ComparePosition( $other, $useLineNo = false) { $thisDomNode = $this->getUnderlyingObject(); $otherDomNode = $other->getUnderlyingObject(); $doc1 = $thisDomNode->baseURI; $doc2 = $otherDomNode->baseURI; if ( strcasecmp( $doc1, $doc2 ) != 0 ) // if ( spl_object_hash( $this->domNode->ownerDocument ) != spl_object_hash( $other->getUnderlyingObject()->ownerDocument ) ) return XmlNodeOrder::Unknown; $thisPath = $thisDomNode->getNodePath(); $otherPath = $otherDomNode->getNodePath(); // Convert node names into a set positions // This is necessary because the getNodePath returns named nodes. // However there has to be a question mark over performance since // an XPath query is being performed for every segment of both the // 'this' path and the 'other' path. // In the case where a parent has named child nodes that are not // in a lexical order such as: // <a> // <c/> // <b/> // </a> // Then sorting on the path will result in a list that is not // document ordered. By changing the name for the correct position // in the parent the set of paths can be sorted. $convert = function( $xPath, $nodePath ) { $parts = explode( "/", $nodePath ); $length = 0; foreach ( $parts as $key => &$part ) { $length++; if ( $part == "" ) continue; $length += strlen( $part ); $result = $xPath->evaluate( "count(" . substr( $nodePath, 0, $length -1 ) . "/preceding-sibling::*) + 1" ); $part = $result; } unset( $part ); return implode( "/", $parts ); }; $xPath = new \DOMXPath( $thisDomNode instanceof \DOMDocument ? $thisDomNode : $thisDomNode->ownerDocument ); $thisPath = $convert( $xPath, $thisPath ); $xPath = new \DOMXPath( $otherDomNode instanceof \DOMDocument ? $otherDomNode : $otherDomNode->ownerDocument ); $otherPath = $convert( $xPath, $otherPath ); if ( $useLineNo ) { $thisPath = $thisDomNode->getLineNo() . "-" . $thisPath; $otherPath = $otherDomNode->getLineNo() . "-" . $otherPath; } // Using strnatcasecmp so /xx[20] will follow /xx[3] which does not happen with other sort types $compare = strnatcasecmp( $thisPath, $otherPath ); return $compare == 0 ? XmlNodeOrder::Same : ( $compare < 0 ? XmlNodeOrder::Before : XmlNodeOrder::After ); }
php
public function ComparePosition( $other, $useLineNo = false) { $thisDomNode = $this->getUnderlyingObject(); $otherDomNode = $other->getUnderlyingObject(); $doc1 = $thisDomNode->baseURI; $doc2 = $otherDomNode->baseURI; if ( strcasecmp( $doc1, $doc2 ) != 0 ) // if ( spl_object_hash( $this->domNode->ownerDocument ) != spl_object_hash( $other->getUnderlyingObject()->ownerDocument ) ) return XmlNodeOrder::Unknown; $thisPath = $thisDomNode->getNodePath(); $otherPath = $otherDomNode->getNodePath(); // Convert node names into a set positions // This is necessary because the getNodePath returns named nodes. // However there has to be a question mark over performance since // an XPath query is being performed for every segment of both the // 'this' path and the 'other' path. // In the case where a parent has named child nodes that are not // in a lexical order such as: // <a> // <c/> // <b/> // </a> // Then sorting on the path will result in a list that is not // document ordered. By changing the name for the correct position // in the parent the set of paths can be sorted. $convert = function( $xPath, $nodePath ) { $parts = explode( "/", $nodePath ); $length = 0; foreach ( $parts as $key => &$part ) { $length++; if ( $part == "" ) continue; $length += strlen( $part ); $result = $xPath->evaluate( "count(" . substr( $nodePath, 0, $length -1 ) . "/preceding-sibling::*) + 1" ); $part = $result; } unset( $part ); return implode( "/", $parts ); }; $xPath = new \DOMXPath( $thisDomNode instanceof \DOMDocument ? $thisDomNode : $thisDomNode->ownerDocument ); $thisPath = $convert( $xPath, $thisPath ); $xPath = new \DOMXPath( $otherDomNode instanceof \DOMDocument ? $otherDomNode : $otherDomNode->ownerDocument ); $otherPath = $convert( $xPath, $otherPath ); if ( $useLineNo ) { $thisPath = $thisDomNode->getLineNo() . "-" . $thisPath; $otherPath = $otherDomNode->getLineNo() . "-" . $otherPath; } // Using strnatcasecmp so /xx[20] will follow /xx[3] which does not happen with other sort types $compare = strnatcasecmp( $thisPath, $otherPath ); return $compare == 0 ? XmlNodeOrder::Same : ( $compare < 0 ? XmlNodeOrder::Before : XmlNodeOrder::After ); }
[ "public", "function", "ComparePosition", "(", "$", "other", ",", "$", "useLineNo", "=", "false", ")", "{", "$", "thisDomNode", "=", "$", "this", "->", "getUnderlyingObject", "(", ")", ";", "$", "otherDomNode", "=", "$", "other", "->", "getUnderlyingObject", "(", ")", ";", "$", "doc1", "=", "$", "thisDomNode", "->", "baseURI", ";", "$", "doc2", "=", "$", "otherDomNode", "->", "baseURI", ";", "if", "(", "strcasecmp", "(", "$", "doc1", ",", "$", "doc2", ")", "!=", "0", ")", "// if ( spl_object_hash( $this->domNode->ownerDocument ) != spl_object_hash( $other->getUnderlyingObject()->ownerDocument ) )\r", "return", "XmlNodeOrder", "::", "Unknown", ";", "$", "thisPath", "=", "$", "thisDomNode", "->", "getNodePath", "(", ")", ";", "$", "otherPath", "=", "$", "otherDomNode", "->", "getNodePath", "(", ")", ";", "// Convert node names into a set positions\r", "// This is necessary because the getNodePath returns named nodes.\r", "// However there has to be a question mark over performance since\r", "// an XPath query is being performed for every segment of both the\r", "// 'this' path and the 'other' path.\r", "// In the case where a parent has named child nodes that are not\r", "// in a lexical order such as:\r", "// <a>\r", "// <c/>\r", "// <b/>\r", "// </a>\r", "// Then sorting on the path will result in a list that is not\r", "// document ordered. By changing the name for the correct position\r", "// in the parent the set of paths can be sorted.\r", "$", "convert", "=", "function", "(", "$", "xPath", ",", "$", "nodePath", ")", "{", "$", "parts", "=", "explode", "(", "\"/\"", ",", "$", "nodePath", ")", ";", "$", "length", "=", "0", ";", "foreach", "(", "$", "parts", "as", "$", "key", "=>", "&", "$", "part", ")", "{", "$", "length", "++", ";", "if", "(", "$", "part", "==", "\"\"", ")", "continue", ";", "$", "length", "+=", "strlen", "(", "$", "part", ")", ";", "$", "result", "=", "$", "xPath", "->", "evaluate", "(", "\"count(\"", ".", "substr", "(", "$", "nodePath", ",", "0", ",", "$", "length", "-", "1", ")", ".", "\"/preceding-sibling::*) + 1\"", ")", ";", "$", "part", "=", "$", "result", ";", "}", "unset", "(", "$", "part", ")", ";", "return", "implode", "(", "\"/\"", ",", "$", "parts", ")", ";", "}", ";", "$", "xPath", "=", "new", "\\", "DOMXPath", "(", "$", "thisDomNode", "instanceof", "\\", "DOMDocument", "?", "$", "thisDomNode", ":", "$", "thisDomNode", "->", "ownerDocument", ")", ";", "$", "thisPath", "=", "$", "convert", "(", "$", "xPath", ",", "$", "thisPath", ")", ";", "$", "xPath", "=", "new", "\\", "DOMXPath", "(", "$", "otherDomNode", "instanceof", "\\", "DOMDocument", "?", "$", "otherDomNode", ":", "$", "otherDomNode", "->", "ownerDocument", ")", ";", "$", "otherPath", "=", "$", "convert", "(", "$", "xPath", ",", "$", "otherPath", ")", ";", "if", "(", "$", "useLineNo", ")", "{", "$", "thisPath", "=", "$", "thisDomNode", "->", "getLineNo", "(", ")", ".", "\"-\"", ".", "$", "thisPath", ";", "$", "otherPath", "=", "$", "otherDomNode", "->", "getLineNo", "(", ")", ".", "\"-\"", ".", "$", "otherPath", ";", "}", "// Using strnatcasecmp so /xx[20] will follow /xx[3] which does not happen with other sort types\r", "$", "compare", "=", "strnatcasecmp", "(", "$", "thisPath", ",", "$", "otherPath", ")", ";", "return", "$", "compare", "==", "0", "?", "XmlNodeOrder", "::", "Same", ":", "(", "$", "compare", "<", "0", "?", "XmlNodeOrder", "::", "Before", ":", "XmlNodeOrder", "::", "After", ")", ";", "}" ]
Compares the position of the current XPathNavigator with the position of the XPathNavigator specified. @param XPathNavigator $other : The XPathNavigator to compare against. @param bool $useLineNo (Default: false) @return XmlNodeOrder An XmlNodeOrder value representing the comparative position of the two XPathNavigator objects.
[ "Compares", "the", "position", "of", "the", "current", "XPathNavigator", "with", "the", "position", "of", "the", "XPathNavigator", "specified", "." ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L155-L217
25,379
bseddon/XPath20
DOM/DOMXPathNavigator.php
DOMXPathNavigator.getLineNo
public function getLineNo() { if ( ! isset( $this->domNode ) || $this->domNode instanceof \DOMDocument ) { return 0; } return $this->domNode->getLineNo(); }
php
public function getLineNo() { if ( ! isset( $this->domNode ) || $this->domNode instanceof \DOMDocument ) { return 0; } return $this->domNode->getLineNo(); }
[ "public", "function", "getLineNo", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "domNode", ")", "||", "$", "this", "->", "domNode", "instanceof", "\\", "DOMDocument", ")", "{", "return", "0", ";", "}", "return", "$", "this", "->", "domNode", "->", "getLineNo", "(", ")", ";", "}" ]
return the line number in the underlying XML document of the current node
[ "return", "the", "line", "number", "in", "the", "underlying", "XML", "document", "of", "the", "current", "node" ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L222-L230
25,380
bseddon/XPath20
DOM/DOMXPathNavigator.php
DOMXPathNavigator.GetAttribute
public function GetAttribute( $localName, $namespaceURI ) { if ( $this->domNode->nodeType != XML_ELEMENT_NODE ) { return ""; } foreach ( $this->domNode->attributes as /** @var \DOMAttr $attribute */ $attribute ) { if ( $attribute->namespaceURI != $namespaceURI || $attribute->localName != $localName ) { continue; } return (string)$attribute->nodeValue; } return ""; }
php
public function GetAttribute( $localName, $namespaceURI ) { if ( $this->domNode->nodeType != XML_ELEMENT_NODE ) { return ""; } foreach ( $this->domNode->attributes as /** @var \DOMAttr $attribute */ $attribute ) { if ( $attribute->namespaceURI != $namespaceURI || $attribute->localName != $localName ) { continue; } return (string)$attribute->nodeValue; } return ""; }
[ "public", "function", "GetAttribute", "(", "$", "localName", ",", "$", "namespaceURI", ")", "{", "if", "(", "$", "this", "->", "domNode", "->", "nodeType", "!=", "XML_ELEMENT_NODE", ")", "{", "return", "\"\"", ";", "}", "foreach", "(", "$", "this", "->", "domNode", "->", "attributes", "as", "/** @var \\DOMAttr $attribute */", "$", "attribute", ")", "{", "if", "(", "$", "attribute", "->", "namespaceURI", "!=", "$", "namespaceURI", "||", "$", "attribute", "->", "localName", "!=", "$", "localName", ")", "{", "continue", ";", "}", "return", "(", "string", ")", "$", "attribute", "->", "nodeValue", ";", "}", "return", "\"\"", ";", "}" ]
Gets the value of the attribute with the specified local name and namespace URI. @param string $localName : The local name of the attribute. @param string $namespaceURI : The namespace URI of the attribute. @return string A string that contains the value of the specified attribute; Empty if a matching attribute is not found, or if the XPathNavigator is not positioned on an element node.
[ "Gets", "the", "value", "of", "the", "attribute", "with", "the", "specified", "local", "name", "and", "namespace", "URI", "." ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L253-L271
25,381
bseddon/XPath20
DOM/DOMXPathNavigator.php
DOMXPathNavigator.getHasChildren
public function getHasChildren( $type = null ) { if ( is_null( $this->domNode ) ) return false; $hasAnyChildren = $this->domNode->hasChildNodes(); if ( ! $hasAnyChildren || is_null( $type ) ) return $hasAnyChildren; $clone = $this->CloneInstance(); return $clone->MoveToChild( $type ); }
php
public function getHasChildren( $type = null ) { if ( is_null( $this->domNode ) ) return false; $hasAnyChildren = $this->domNode->hasChildNodes(); if ( ! $hasAnyChildren || is_null( $type ) ) return $hasAnyChildren; $clone = $this->CloneInstance(); return $clone->MoveToChild( $type ); }
[ "public", "function", "getHasChildren", "(", "$", "type", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "domNode", ")", ")", "return", "false", ";", "$", "hasAnyChildren", "=", "$", "this", "->", "domNode", "->", "hasChildNodes", "(", ")", ";", "if", "(", "!", "$", "hasAnyChildren", "||", "is_null", "(", "$", "type", ")", ")", "return", "$", "hasAnyChildren", ";", "$", "clone", "=", "$", "this", "->", "CloneInstance", "(", ")", ";", "return", "$", "clone", "->", "MoveToChild", "(", "$", "type", ")", ";", "}" ]
Not used but implement Gets a value indicating whether the current node has any child nodes. @param XPathNodeType $type @return bool $HasChildren true if the current node has any child nodes; otherwise, false.
[ "Not", "used", "but", "implement", "Gets", "a", "value", "indicating", "whether", "the", "current", "node", "has", "any", "child", "nodes", "." ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L305-L313
25,382
bseddon/XPath20
DOM/DOMXPathNavigator.php
DOMXPathNavigator.getInnerXml
public function getInnerXml() { if ( is_null( $this->domNode ) ) return null; $owner = $this->domNode instanceof \DOMDocument ? $this->domNode : $this->domNode->ownerDocument; $xml = $owner->saveXml( $this->domNode, LIBXML_NOEMPTYTAG ); $xml = ltrim( preg_replace( "/^<\?xml.*\?>/", "", $xml ) ); $xml = ltrim( preg_replace( "/^<!DOCTYPE[^>[]*(\[[^]]*\])?>/s", "", $xml ) ); return $xml; }
php
public function getInnerXml() { if ( is_null( $this->domNode ) ) return null; $owner = $this->domNode instanceof \DOMDocument ? $this->domNode : $this->domNode->ownerDocument; $xml = $owner->saveXml( $this->domNode, LIBXML_NOEMPTYTAG ); $xml = ltrim( preg_replace( "/^<\?xml.*\?>/", "", $xml ) ); $xml = ltrim( preg_replace( "/^<!DOCTYPE[^>[]*(\[[^]]*\])?>/s", "", $xml ) ); return $xml; }
[ "public", "function", "getInnerXml", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "domNode", ")", ")", "return", "null", ";", "$", "owner", "=", "$", "this", "->", "domNode", "instanceof", "\\", "DOMDocument", "?", "$", "this", "->", "domNode", ":", "$", "this", "->", "domNode", "->", "ownerDocument", ";", "$", "xml", "=", "$", "owner", "->", "saveXml", "(", "$", "this", "->", "domNode", ",", "LIBXML_NOEMPTYTAG", ")", ";", "$", "xml", "=", "ltrim", "(", "preg_replace", "(", "\"/^<\\?xml.*\\?>/\"", ",", "\"\"", ",", "$", "xml", ")", ")", ";", "$", "xml", "=", "ltrim", "(", "preg_replace", "(", "\"/^<!DOCTYPE[^>[]*(\\[[^]]*\\])?>/s\"", ",", "\"\"", ",", "$", "xml", ")", ")", ";", "return", "$", "xml", ";", "}" ]
Not used but implement Gets or sets the markup representing the child nodes of the current node. @return string A string that contains the markup of the child nodes of the current node.
[ "Not", "used", "but", "implement", "Gets", "or", "sets", "the", "markup", "representing", "the", "child", "nodes", "of", "the", "current", "node", "." ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L321-L329
25,383
bseddon/XPath20
DOM/DOMXPathNavigator.php
DOMXPathNavigator.getLocalName
public function getLocalName() { if ( is_null( $this->domNode ) ) return null; if ( $this->domNode instanceof \DOMNameSpaceNode ) { return $this->domNode->localName; } else { return $this->domNode->nodeType == XPathNodeType::ProcessingInstruction ? "{$this->domNode->nodeName}" : "{$this->domNode->localName}"; } }
php
public function getLocalName() { if ( is_null( $this->domNode ) ) return null; if ( $this->domNode instanceof \DOMNameSpaceNode ) { return $this->domNode->localName; } else { return $this->domNode->nodeType == XPathNodeType::ProcessingInstruction ? "{$this->domNode->nodeName}" : "{$this->domNode->localName}"; } }
[ "public", "function", "getLocalName", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "domNode", ")", ")", "return", "null", ";", "if", "(", "$", "this", "->", "domNode", "instanceof", "\\", "DOMNameSpaceNode", ")", "{", "return", "$", "this", "->", "domNode", "->", "localName", ";", "}", "else", "{", "return", "$", "this", "->", "domNode", "->", "nodeType", "==", "XPathNodeType", "::", "ProcessingInstruction", "?", "\"{$this->domNode->nodeName}\"", ":", "\"{$this->domNode->localName}\"", ";", "}", "}" ]
When overridden in a derived class, gets the XPathNavigator.Name of the current node without any namespace prefix. @return string A string that contains the local name of the current node, or Empty if the current node does not have a name (for example, text or comment nodes).
[ "When", "overridden", "in", "a", "derived", "class", "gets", "the", "XPathNavigator", ".", "Name", "of", "the", "current", "node", "without", "any", "namespace", "prefix", "." ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L350-L363
25,384
bseddon/XPath20
DOM/DOMXPathNavigator.php
DOMXPathNavigator.getName
public function getName() { if ( is_null( $this->domNode ) ) return null; if ( $this->domNode instanceof \DOMNameSpaceNode ) { return $this->domNode->prefix; } else { return empty( $this->domNode->prefix ) ? "{$this->domNode->localName}" : "{$this->domNode->prefix}:{$this->domNode->localName}"; } }
php
public function getName() { if ( is_null( $this->domNode ) ) return null; if ( $this->domNode instanceof \DOMNameSpaceNode ) { return $this->domNode->prefix; } else { return empty( $this->domNode->prefix ) ? "{$this->domNode->localName}" : "{$this->domNode->prefix}:{$this->domNode->localName}"; } }
[ "public", "function", "getName", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "domNode", ")", ")", "return", "null", ";", "if", "(", "$", "this", "->", "domNode", "instanceof", "\\", "DOMNameSpaceNode", ")", "{", "return", "$", "this", "->", "domNode", "->", "prefix", ";", "}", "else", "{", "return", "empty", "(", "$", "this", "->", "domNode", "->", "prefix", ")", "?", "\"{$this->domNode->localName}\"", ":", "\"{$this->domNode->prefix}:{$this->domNode->localName}\"", ";", "}", "}" ]
When overridden in a derived class, gets the qualified name of the current node. @return string A string that contains the qualified XPathNavigator.Name of the current node, or Empty if the current node does not have a name (for example, text or comment nodes).
[ "When", "overridden", "in", "a", "derived", "class", "gets", "the", "qualified", "name", "of", "the", "current", "node", "." ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L372-L386
25,385
bseddon/XPath20
DOM/DOMXPathNavigator.php
DOMXPathNavigator.getNamespaceURI
public function getNamespaceURI() { if ( is_null( $this->domNode ) ) return null; return is_null( $this->domNode->namespaceURI ) ? "" : $this->domNode->namespaceURI; }
php
public function getNamespaceURI() { if ( is_null( $this->domNode ) ) return null; return is_null( $this->domNode->namespaceURI ) ? "" : $this->domNode->namespaceURI; }
[ "public", "function", "getNamespaceURI", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "domNode", ")", ")", "return", "null", ";", "return", "is_null", "(", "$", "this", "->", "domNode", "->", "namespaceURI", ")", "?", "\"\"", ":", "$", "this", "->", "domNode", "->", "namespaceURI", ";", "}" ]
When overridden in a derived class, gets the namespace URI of the current node. @return string A string that contains the namespace URI of the current node, or Empty if the current node has no namespace URI.
[ "When", "overridden", "in", "a", "derived", "class", "gets", "the", "namespace", "URI", "of", "the", "current", "node", "." ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L394-L398
25,386
bseddon/XPath20
DOM/DOMXPathNavigator.php
DOMXPathNavigator.getNodeType
public function getNodeType() { if ( is_null( $this->domNode ) ) return null; return isset( DOMXPathNavigator::$nodeTypeMap[ $this->domNode->nodeType ] ) ? DOMXPathNavigator::$nodeTypeMap[ $this->domNode->nodeType ] : XPathNodeType::Element; }
php
public function getNodeType() { if ( is_null( $this->domNode ) ) return null; return isset( DOMXPathNavigator::$nodeTypeMap[ $this->domNode->nodeType ] ) ? DOMXPathNavigator::$nodeTypeMap[ $this->domNode->nodeType ] : XPathNodeType::Element; }
[ "public", "function", "getNodeType", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "domNode", ")", ")", "return", "null", ";", "return", "isset", "(", "DOMXPathNavigator", "::", "$", "nodeTypeMap", "[", "$", "this", "->", "domNode", "->", "nodeType", "]", ")", "?", "DOMXPathNavigator", "::", "$", "nodeTypeMap", "[", "$", "this", "->", "domNode", "->", "nodeType", "]", ":", "XPathNodeType", "::", "Element", ";", "}" ]
When overridden in a derived class, gets the XPathNodeType of the current node. @return XPathNodeType One of the XPathNodeType values representing the current node.
[ "When", "overridden", "in", "a", "derived", "class", "gets", "the", "XPathNodeType", "of", "the", "current", "node", "." ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L416-L422
25,387
bseddon/XPath20
DOM/DOMXPathNavigator.php
DOMXPathNavigator.getOuterXml
public function getOuterXml() { if ( is_null( $this->domNode ) ) return ""; return is_null( $this->domNode->parentNode ) ? $this->domNode->ownerDocument->saveXml( $this->domNode ) : $this->domNode->ownerDocument->saveXml( $this->domNode->parentNode ); }
php
public function getOuterXml() { if ( is_null( $this->domNode ) ) return ""; return is_null( $this->domNode->parentNode ) ? $this->domNode->ownerDocument->saveXml( $this->domNode ) : $this->domNode->ownerDocument->saveXml( $this->domNode->parentNode ); }
[ "public", "function", "getOuterXml", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "domNode", ")", ")", "return", "\"\"", ";", "return", "is_null", "(", "$", "this", "->", "domNode", "->", "parentNode", ")", "?", "$", "this", "->", "domNode", "->", "ownerDocument", "->", "saveXml", "(", "$", "this", "->", "domNode", ")", ":", "$", "this", "->", "domNode", "->", "ownerDocument", "->", "saveXml", "(", "$", "this", "->", "domNode", "->", "parentNode", ")", ";", "}" ]
Gets or sets the markup representing the opening and closing tags of the current node and its child nodes. @return string A string that contains the markup representing the opening and closing tags of the current node and its child nodes.
[ "Gets", "or", "sets", "the", "markup", "representing", "the", "opening", "and", "closing", "tags", "of", "the", "current", "node", "and", "its", "child", "nodes", "." ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L430-L436
25,388
bseddon/XPath20
DOM/DOMXPathNavigator.php
DOMXPathNavigator.getSchemaInfo
public function getSchemaInfo() { if ( is_null( $this->domNode ) ) return null; switch( $this->domNode->nodeType ) { case XML_ATTRIBUTE_NODE: case XML_ELEMENT_NODE: return new DOMName( $this->domNode ); case XML_TEXT_NODE: return new DOMName( $this->domNode->parentNode ); default: return new DOMSchemaInfo( $this->domNode ); } }
php
public function getSchemaInfo() { if ( is_null( $this->domNode ) ) return null; switch( $this->domNode->nodeType ) { case XML_ATTRIBUTE_NODE: case XML_ELEMENT_NODE: return new DOMName( $this->domNode ); case XML_TEXT_NODE: return new DOMName( $this->domNode->parentNode ); default: return new DOMSchemaInfo( $this->domNode ); } }
[ "public", "function", "getSchemaInfo", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "domNode", ")", ")", "return", "null", ";", "switch", "(", "$", "this", "->", "domNode", "->", "nodeType", ")", "{", "case", "XML_ATTRIBUTE_NODE", ":", "case", "XML_ELEMENT_NODE", ":", "return", "new", "DOMName", "(", "$", "this", "->", "domNode", ")", ";", "case", "XML_TEXT_NODE", ":", "return", "new", "DOMName", "(", "$", "this", "->", "domNode", "->", "parentNode", ")", ";", "default", ":", "return", "new", "DOMSchemaInfo", "(", "$", "this", "->", "domNode", ")", ";", "}", "}" ]
Gets the schema information that has been assigned to the current node as a result of schema validation. @return IXmlSchemaInfo An IXmlSchemaInfo object that contains the schema information for the current node.
[ "Gets", "the", "schema", "information", "that", "has", "been", "assigned", "to", "the", "current", "node", "as", "a", "result", "of", "schema", "validation", "." ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L455-L471
25,389
bseddon/XPath20
DOM/DOMXPathNavigator.php
DOMXPathNavigator.CloneInstance
public function CloneInstance() { // Clone in this sense means be able to have a different current position so creating a new // DOMXPathNavigator instance should be sufficient. There is no need to clone the current node. return is_null( $this->domNode ) ? $this : new DOMXPathNavigator( $this->domNode, $this->nsManager, $this->nsTable ); }
php
public function CloneInstance() { // Clone in this sense means be able to have a different current position so creating a new // DOMXPathNavigator instance should be sufficient. There is no need to clone the current node. return is_null( $this->domNode ) ? $this : new DOMXPathNavigator( $this->domNode, $this->nsManager, $this->nsTable ); }
[ "public", "function", "CloneInstance", "(", ")", "{", "// Clone in this sense means be able to have a different current position so creating a new\r", "// DOMXPathNavigator instance should be sufficient. There is no need to clone the current node.\r", "return", "is_null", "(", "$", "this", "->", "domNode", ")", "?", "$", "this", ":", "new", "DOMXPathNavigator", "(", "$", "this", "->", "domNode", ",", "$", "this", "->", "nsManager", ",", "$", "this", "->", "nsTable", ")", ";", "}" ]
When overridden in a derived class, creates a new XPathNavigator positioned at the same node as this XPathNavigator. @return XPathNavigator A new XPathNavigator positioned at the same node as this XPathNavigator.
[ "When", "overridden", "in", "a", "derived", "class", "creates", "a", "new", "XPathNavigator", "positioned", "at", "the", "same", "node", "as", "this", "XPathNavigator", "." ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L585-L592
25,390
bseddon/XPath20
DOM/DOMXPathNavigator.php
DOMXPathNavigator.IsSamePosition
public function IsSamePosition( $other ) { if ( is_null( $this->domNode ) || is_null( $other ) ) return false; return $this->domNode->isSameNode( $other->getUnderlyingObject() ); }
php
public function IsSamePosition( $other ) { if ( is_null( $this->domNode ) || is_null( $other ) ) return false; return $this->domNode->isSameNode( $other->getUnderlyingObject() ); }
[ "public", "function", "IsSamePosition", "(", "$", "other", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "domNode", ")", "||", "is_null", "(", "$", "other", ")", ")", "return", "false", ";", "return", "$", "this", "->", "domNode", "->", "isSameNode", "(", "$", "other", "->", "getUnderlyingObject", "(", ")", ")", ";", "}" ]
When overridden in a derived class, determines whether the current XPathNavigator is at the same position as the specified XPathNavigator. @param XPathNavigator $other : The XPathNavigator to compare to this XPathNavigator. @return bool true if the two XPathNavigator objects have the same position; otherwise, false.
[ "When", "overridden", "in", "a", "derived", "class", "determines", "whether", "the", "current", "XPathNavigator", "is", "at", "the", "same", "position", "as", "the", "specified", "XPathNavigator", "." ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L602-L606
25,391
bseddon/XPath20
DOM/DOMXPathNavigator.php
DOMXPathNavigator.MoveTo
public function MoveTo( $other ) { if ( is_null( $this->domNode ) || is_null( $other ) ) return false; // Replace the domNode with a clone of the one from $other $this->domNode = $other->getUnderlyingObject(); // ->cloneNode(); return true; }
php
public function MoveTo( $other ) { if ( is_null( $this->domNode ) || is_null( $other ) ) return false; // Replace the domNode with a clone of the one from $other $this->domNode = $other->getUnderlyingObject(); // ->cloneNode(); return true; }
[ "public", "function", "MoveTo", "(", "$", "other", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "domNode", ")", "||", "is_null", "(", "$", "other", ")", ")", "return", "false", ";", "// Replace the domNode with a clone of the one from $other\r", "$", "this", "->", "domNode", "=", "$", "other", "->", "getUnderlyingObject", "(", ")", ";", "// ->cloneNode();\r", "return", "true", ";", "}" ]
When overridden in a derived class, moves the XPathNavigator to the same position as the specified XPathNavigator. @param XPathNavigator $other : The XPathNavigator positioned on the node that you want to move to. @return bool true if the XPathNavigator is successful moving to the same position as the specified XPathNavigator; otherwise, false. If false, the position of the XPathNavigator is unchanged.
[ "When", "overridden", "in", "a", "derived", "class", "moves", "the", "XPathNavigator", "to", "the", "same", "position", "as", "the", "specified", "XPathNavigator", "." ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L630-L637
25,392
bseddon/XPath20
DOM/DOMXPathNavigator.php
DOMXPathNavigator.MoveToChild
public function MoveToChild( $kind ) { if ( is_null( $this->domNode ) || is_null( $kind ) || ! property_exists( $this->domNode, 'firstChild') // || // ! $this->domNode->hasChildNodes() ) return false; // Create a list of the valid DOM node types based on the $kind value $domNodeTypes = array_keys( array_filter( \lyquidity\XPath2\DOM\DOMXPathNavigator::$nodeTypeMap, function( $nodeType ) use( $kind ) { return $kind == \lyquidity\xml\xpath\XPathNodeType::All || $nodeType == $kind; } ) ); // Take a copy of the dom node /** @var \DOMNode $next */ $next = $this->domNode->firstChild; if ( is_null( $next ) ) return; do { // If the $next node type is valid then store the next node type as the new dom node and return true if ( in_array( $next->nodeType, $domNodeTypes ) ) { $this->domNode = $next; return true; } } while( ! is_null( $next = $next->nextSibling ) ); return false; }
php
public function MoveToChild( $kind ) { if ( is_null( $this->domNode ) || is_null( $kind ) || ! property_exists( $this->domNode, 'firstChild') // || // ! $this->domNode->hasChildNodes() ) return false; // Create a list of the valid DOM node types based on the $kind value $domNodeTypes = array_keys( array_filter( \lyquidity\XPath2\DOM\DOMXPathNavigator::$nodeTypeMap, function( $nodeType ) use( $kind ) { return $kind == \lyquidity\xml\xpath\XPathNodeType::All || $nodeType == $kind; } ) ); // Take a copy of the dom node /** @var \DOMNode $next */ $next = $this->domNode->firstChild; if ( is_null( $next ) ) return; do { // If the $next node type is valid then store the next node type as the new dom node and return true if ( in_array( $next->nodeType, $domNodeTypes ) ) { $this->domNode = $next; return true; } } while( ! is_null( $next = $next->nextSibling ) ); return false; }
[ "public", "function", "MoveToChild", "(", "$", "kind", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "domNode", ")", "||", "is_null", "(", "$", "kind", ")", "||", "!", "property_exists", "(", "$", "this", "->", "domNode", ",", "'firstChild'", ")", "// ||\r", "// ! $this->domNode->hasChildNodes()\r", ")", "return", "false", ";", "// Create a list of the valid DOM node types based on the $kind value\r", "$", "domNodeTypes", "=", "array_keys", "(", "array_filter", "(", "\\", "lyquidity", "\\", "XPath2", "\\", "DOM", "\\", "DOMXPathNavigator", "::", "$", "nodeTypeMap", ",", "function", "(", "$", "nodeType", ")", "use", "(", "$", "kind", ")", "{", "return", "$", "kind", "==", "\\", "lyquidity", "\\", "xml", "\\", "xpath", "\\", "XPathNodeType", "::", "All", "||", "$", "nodeType", "==", "$", "kind", ";", "}", ")", ")", ";", "// Take a copy of the dom node\r", "/** @var \\DOMNode $next */", "$", "next", "=", "$", "this", "->", "domNode", "->", "firstChild", ";", "if", "(", "is_null", "(", "$", "next", ")", ")", "return", ";", "do", "{", "// If the $next node type is valid then store the next node type as the new dom node and return true\r", "if", "(", "in_array", "(", "$", "next", "->", "nodeType", ",", "$", "domNodeTypes", ")", ")", "{", "$", "this", "->", "domNode", "=", "$", "next", ";", "return", "true", ";", "}", "}", "while", "(", "!", "is_null", "(", "$", "next", "=", "$", "next", "->", "nextSibling", ")", ")", ";", "return", "false", ";", "}" ]
Moves the XPathNavigator to the child node of the XPathNodeType specified. @param XPathNodeType $kind The XPathNodeType of the child node to move to. @return bool Returns true if the XPathNavigator is successful moving to the child node; otherwise, false. If false, the position of the XPathNavigator is unchanged.
[ "Moves", "the", "XPathNavigator", "to", "the", "child", "node", "of", "the", "XPathNodeType", "specified", "." ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L646-L680
25,393
bseddon/XPath20
DOM/DOMXPathNavigator.php
DOMXPathNavigator.MoveToFirstAttribute
public function MoveToFirstAttribute() { // If the current node is already an attribute or there are no attributes return false if ( is_null( $this->domNode ) || $this->domNode instanceof \DOMAttr || ! $this->domNode->hasAttributes() ) return false; $this->domNode = $this->domNode->attributes->item(0); return true; }
php
public function MoveToFirstAttribute() { // If the current node is already an attribute or there are no attributes return false if ( is_null( $this->domNode ) || $this->domNode instanceof \DOMAttr || ! $this->domNode->hasAttributes() ) return false; $this->domNode = $this->domNode->attributes->item(0); return true; }
[ "public", "function", "MoveToFirstAttribute", "(", ")", "{", "// If the current node is already an attribute or there are no attributes return false\r", "if", "(", "is_null", "(", "$", "this", "->", "domNode", ")", "||", "$", "this", "->", "domNode", "instanceof", "\\", "DOMAttr", "||", "!", "$", "this", "->", "domNode", "->", "hasAttributes", "(", ")", ")", "return", "false", ";", "$", "this", "->", "domNode", "=", "$", "this", "->", "domNode", "->", "attributes", "->", "item", "(", "0", ")", ";", "return", "true", ";", "}" ]
When overridden in a derived class, moves the XPathNavigator to the first attribute of the current node. @return bool Returns true if the XPathNavigator is successful moving to the first attribute of the current node; otherwise, false. If false, the position of the XPathNavigator is unchanged.
[ "When", "overridden", "in", "a", "derived", "class", "moves", "the", "XPathNavigator", "to", "the", "first", "attribute", "of", "the", "current", "node", "." ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L688-L695
25,394
bseddon/XPath20
DOM/DOMXPathNavigator.php
DOMXPathNavigator.MoveToAttribute
public function MoveToAttribute( $localName, $namespaceURI ) { if ( ! $this->MoveToFirstAttribute() ) { return false; } do { if ( $this->getLocalName() == $localName && ( ( is_null( $namespaceURI ) && empty( $this->getNamespaceURI() ) ) || $this->getNamespaceURI() == $namespaceURI ) ) { return true; } } while ( $this->MoveToNextAttribute() ); // If any attribute was found but not the desired attribute return to the parent $this->MoveToParent(); return false; }
php
public function MoveToAttribute( $localName, $namespaceURI ) { if ( ! $this->MoveToFirstAttribute() ) { return false; } do { if ( $this->getLocalName() == $localName && ( ( is_null( $namespaceURI ) && empty( $this->getNamespaceURI() ) ) || $this->getNamespaceURI() == $namespaceURI ) ) { return true; } } while ( $this->MoveToNextAttribute() ); // If any attribute was found but not the desired attribute return to the parent $this->MoveToParent(); return false; }
[ "public", "function", "MoveToAttribute", "(", "$", "localName", ",", "$", "namespaceURI", ")", "{", "if", "(", "!", "$", "this", "->", "MoveToFirstAttribute", "(", ")", ")", "{", "return", "false", ";", "}", "do", "{", "if", "(", "$", "this", "->", "getLocalName", "(", ")", "==", "$", "localName", "&&", "(", "(", "is_null", "(", "$", "namespaceURI", ")", "&&", "empty", "(", "$", "this", "->", "getNamespaceURI", "(", ")", ")", ")", "||", "$", "this", "->", "getNamespaceURI", "(", ")", "==", "$", "namespaceURI", ")", ")", "{", "return", "true", ";", "}", "}", "while", "(", "$", "this", "->", "MoveToNextAttribute", "(", ")", ")", ";", "// If any attribute was found but not the desired attribute return to the parent\r", "$", "this", "->", "MoveToParent", "(", ")", ";", "return", "false", ";", "}" ]
Moves the XPathNavigator to the attribute with the matching local name and namespace URI. @param string $localName : The local name of the attribute. @param string $namespaceURI : The namespace URI of the attribute; null for an empty namespace. @return bool Returns true if the XPathNavigator is successful moving to the attribute; otherwise, false. If false, the position of the XPathNavigator is unchanged.
[ "Moves", "the", "XPathNavigator", "to", "the", "attribute", "with", "the", "matching", "local", "name", "and", "namespace", "URI", "." ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L706-L725
25,395
bseddon/XPath20
DOM/DOMXPathNavigator.php
DOMXPathNavigator.MoveToFirstChild
public function MoveToFirstChild() { if ( is_null( $this->domNode ) || ( ! $this->domNode instanceof \DOMDocument && ! $this->domNode instanceof \DOMElement ) || ! $this->domNode->hasChildNodes() ) return false; // if ( $this->domNode instanceof \DOMDocument ) // { // $this->domNode = $this->domNode->documentElement; // return true; // } $this->domNode = $this->domNode->firstChild; return true; }
php
public function MoveToFirstChild() { if ( is_null( $this->domNode ) || ( ! $this->domNode instanceof \DOMDocument && ! $this->domNode instanceof \DOMElement ) || ! $this->domNode->hasChildNodes() ) return false; // if ( $this->domNode instanceof \DOMDocument ) // { // $this->domNode = $this->domNode->documentElement; // return true; // } $this->domNode = $this->domNode->firstChild; return true; }
[ "public", "function", "MoveToFirstChild", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "domNode", ")", "||", "(", "!", "$", "this", "->", "domNode", "instanceof", "\\", "DOMDocument", "&&", "!", "$", "this", "->", "domNode", "instanceof", "\\", "DOMElement", ")", "||", "!", "$", "this", "->", "domNode", "->", "hasChildNodes", "(", ")", ")", "return", "false", ";", "// if ( $this->domNode instanceof \\DOMDocument )\r", "// {\r", "// \t$this->domNode = $this->domNode->documentElement;\r", "// \treturn true;\r", "// }\r", "$", "this", "->", "domNode", "=", "$", "this", "->", "domNode", "->", "firstChild", ";", "return", "true", ";", "}" ]
When overridden in a derived class, moves the XPathNavigator to the first child node of the current node. @return bool Returns true if the XPathNavigator is successful moving to the first child node of the current node; otherwise, false. If false, the position of the XPathNavigator is unchanged.
[ "When", "overridden", "in", "a", "derived", "class", "moves", "the", "XPathNavigator", "to", "the", "first", "child", "node", "of", "the", "current", "node", "." ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L733-L749
25,396
bseddon/XPath20
DOM/DOMXPathNavigator.php
DOMXPathNavigator.MoveToFirstNamespace
public function MoveToFirstNamespace( $namespaceScope = XPathNamespaceScope::Local ) { if ( is_null( $this->domNode ) ) return false; if ( $this->domNode->nodeType != XML_ELEMENT_NODE && $this->domNode->nodeType != XML_DOCUMENT_NODE ) return false; $expression = $namespaceScope == XPathNamespaceScope::Local ? 'namespace::*[not(. = ../../namespace::*)]' : 'namespace::*'; $xpath = new \DOMXPath( $this->domNode->nodeType == XML_DOCUMENT_NODE ? $this->domNode : $this->domNode->ownerDocument ); $namespaces = $xpath->query( $expression, $this->domNode ); if ( ! $namespaces || $namespaces->length == 0 ) return false; $this->domNode = $namespaces[ $namespaces->length - 1 ]; return true; }
php
public function MoveToFirstNamespace( $namespaceScope = XPathNamespaceScope::Local ) { if ( is_null( $this->domNode ) ) return false; if ( $this->domNode->nodeType != XML_ELEMENT_NODE && $this->domNode->nodeType != XML_DOCUMENT_NODE ) return false; $expression = $namespaceScope == XPathNamespaceScope::Local ? 'namespace::*[not(. = ../../namespace::*)]' : 'namespace::*'; $xpath = new \DOMXPath( $this->domNode->nodeType == XML_DOCUMENT_NODE ? $this->domNode : $this->domNode->ownerDocument ); $namespaces = $xpath->query( $expression, $this->domNode ); if ( ! $namespaces || $namespaces->length == 0 ) return false; $this->domNode = $namespaces[ $namespaces->length - 1 ]; return true; }
[ "public", "function", "MoveToFirstNamespace", "(", "$", "namespaceScope", "=", "XPathNamespaceScope", "::", "Local", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "domNode", ")", ")", "return", "false", ";", "if", "(", "$", "this", "->", "domNode", "->", "nodeType", "!=", "XML_ELEMENT_NODE", "&&", "$", "this", "->", "domNode", "->", "nodeType", "!=", "XML_DOCUMENT_NODE", ")", "return", "false", ";", "$", "expression", "=", "$", "namespaceScope", "==", "XPathNamespaceScope", "::", "Local", "?", "'namespace::*[not(. = ../../namespace::*)]'", ":", "'namespace::*'", ";", "$", "xpath", "=", "new", "\\", "DOMXPath", "(", "$", "this", "->", "domNode", "->", "nodeType", "==", "XML_DOCUMENT_NODE", "?", "$", "this", "->", "domNode", ":", "$", "this", "->", "domNode", "->", "ownerDocument", ")", ";", "$", "namespaces", "=", "$", "xpath", "->", "query", "(", "$", "expression", ",", "$", "this", "->", "domNode", ")", ";", "if", "(", "!", "$", "namespaces", "||", "$", "namespaces", "->", "length", "==", "0", ")", "return", "false", ";", "$", "this", "->", "domNode", "=", "$", "namespaces", "[", "$", "namespaces", "->", "length", "-", "1", "]", ";", "return", "true", ";", "}" ]
When overridden in a derived class, moves the XPathNavigator to the first namespace node that matches the XPathNamespaceScope specified. @param XPathNamespaceScope namespaceScope : An XPathNamespaceScope value describing the namespace scope. @return bool Returns true if the XPathNavigator is successful moving to the first namespace node; otherwise, false. If false, the position of the XPathNavigator is unchanged.
[ "When", "overridden", "in", "a", "derived", "class", "moves", "the", "XPathNavigator", "to", "the", "first", "namespace", "node", "that", "matches", "the", "XPathNamespaceScope", "specified", "." ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L760-L776
25,397
bseddon/XPath20
DOM/DOMXPathNavigator.php
DOMXPathNavigator.MoveToFirst
public function MoveToFirst() { if ( ! isset( $this->domNode ) || ! $this->getIsNode() ) return false; // The DOMDocument and document element are their own first siblings if ( $this->domNode instanceof \DOMDocument || $this->domNode->parentNode instanceof \DOMDocument ) return true; $this->domNode = $this->domNode->parentNode->firstChild; return true; }
php
public function MoveToFirst() { if ( ! isset( $this->domNode ) || ! $this->getIsNode() ) return false; // The DOMDocument and document element are their own first siblings if ( $this->domNode instanceof \DOMDocument || $this->domNode->parentNode instanceof \DOMDocument ) return true; $this->domNode = $this->domNode->parentNode->firstChild; return true; }
[ "public", "function", "MoveToFirst", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "domNode", ")", "||", "!", "$", "this", "->", "getIsNode", "(", ")", ")", "return", "false", ";", "// The DOMDocument and document element are their own first siblings\r", "if", "(", "$", "this", "->", "domNode", "instanceof", "\\", "DOMDocument", "||", "$", "this", "->", "domNode", "->", "parentNode", "instanceof", "\\", "DOMDocument", ")", "return", "true", ";", "$", "this", "->", "domNode", "=", "$", "this", "->", "domNode", "->", "parentNode", "->", "firstChild", ";", "return", "true", ";", "}" ]
Moves the XPathNavigator to the first sibling node of the current node. @return bool Returns true if the XPathNavigator is successful moving to the first sibling node of the current node; false if there is no first sibling, or if the XPathNavigator is currently positioned on an attribute node. If the XPathNavigator is already positioned on the first sibling, XPathNavigator will return true and will not move its position.If XPathNavigator.MoveToFirst returns false because there is no first sibling, or if XPathNavigator is currently positioned on an attribute, the position of the XPathNavigator is unchanged.
[ "Moves", "the", "XPathNavigator", "to", "the", "first", "sibling", "node", "of", "the", "current", "node", "." ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L805-L814
25,398
bseddon/XPath20
DOM/DOMXPathNavigator.php
DOMXPathNavigator.MoveToFollowing
public function MoveToFollowing( $kind, $end = null ) { if ( is_null( $this->domNode ) || is_null( $kind ) || $this->domNode instanceof \DOMAttr || $this->domNode instanceof \DOMNameSpaceNode ) return false; if ( ! is_null( $end ) && $this->IsSamePosition( $end ) ) return false; if ( $this->domNode instanceof \DOMDocument ) { $this->domNode = $this->domNode->documentElement; return true; } /** * @var \DOMElement $node */ $node = $this->domNode; while( true ) { if ( $node->hasChildNodes() ) { $node = $node->firstChild; } else { while( true ) { if ( is_null( $node->nextSibling ) ) { if ( $node->parentNode instanceof \DOMDocument ) return false; $node = $node->parentNode; } else { $node = $node->nextSibling; if ( ! is_null( $end ) && $node->isSameNode( $end->getUnderlyingObject() ) ) return false; break; } } } if ( XPathNodeType::All == $kind || $node->nodeType == $kind ) break; } $this->domNode = $node; return true; }
php
public function MoveToFollowing( $kind, $end = null ) { if ( is_null( $this->domNode ) || is_null( $kind ) || $this->domNode instanceof \DOMAttr || $this->domNode instanceof \DOMNameSpaceNode ) return false; if ( ! is_null( $end ) && $this->IsSamePosition( $end ) ) return false; if ( $this->domNode instanceof \DOMDocument ) { $this->domNode = $this->domNode->documentElement; return true; } /** * @var \DOMElement $node */ $node = $this->domNode; while( true ) { if ( $node->hasChildNodes() ) { $node = $node->firstChild; } else { while( true ) { if ( is_null( $node->nextSibling ) ) { if ( $node->parentNode instanceof \DOMDocument ) return false; $node = $node->parentNode; } else { $node = $node->nextSibling; if ( ! is_null( $end ) && $node->isSameNode( $end->getUnderlyingObject() ) ) return false; break; } } } if ( XPathNodeType::All == $kind || $node->nodeType == $kind ) break; } $this->domNode = $node; return true; }
[ "public", "function", "MoveToFollowing", "(", "$", "kind", ",", "$", "end", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "domNode", ")", "||", "is_null", "(", "$", "kind", ")", "||", "$", "this", "->", "domNode", "instanceof", "\\", "DOMAttr", "||", "$", "this", "->", "domNode", "instanceof", "\\", "DOMNameSpaceNode", ")", "return", "false", ";", "if", "(", "!", "is_null", "(", "$", "end", ")", "&&", "$", "this", "->", "IsSamePosition", "(", "$", "end", ")", ")", "return", "false", ";", "if", "(", "$", "this", "->", "domNode", "instanceof", "\\", "DOMDocument", ")", "{", "$", "this", "->", "domNode", "=", "$", "this", "->", "domNode", "->", "documentElement", ";", "return", "true", ";", "}", "/**\r\n\t\t * @var \\DOMElement $node\r\n\t\t */", "$", "node", "=", "$", "this", "->", "domNode", ";", "while", "(", "true", ")", "{", "if", "(", "$", "node", "->", "hasChildNodes", "(", ")", ")", "{", "$", "node", "=", "$", "node", "->", "firstChild", ";", "}", "else", "{", "while", "(", "true", ")", "{", "if", "(", "is_null", "(", "$", "node", "->", "nextSibling", ")", ")", "{", "if", "(", "$", "node", "->", "parentNode", "instanceof", "\\", "DOMDocument", ")", "return", "false", ";", "$", "node", "=", "$", "node", "->", "parentNode", ";", "}", "else", "{", "$", "node", "=", "$", "node", "->", "nextSibling", ";", "if", "(", "!", "is_null", "(", "$", "end", ")", "&&", "$", "node", "->", "isSameNode", "(", "$", "end", "->", "getUnderlyingObject", "(", ")", ")", ")", "return", "false", ";", "break", ";", "}", "}", "}", "if", "(", "XPathNodeType", "::", "All", "==", "$", "kind", "||", "$", "node", "->", "nodeType", "==", "$", "kind", ")", "break", ";", "}", "$", "this", "->", "domNode", "=", "$", "node", ";", "return", "true", ";", "}" ]
Moves the XPathNavigator to the following element of the XPathNodeType specified, to the boundary specified, in document order. @param XPathNodeType $kind : The XPathNodeType of the element. The XPathNodeType cannot be XPathNodeType.Attribute or XPathNodeType.Namespace. @param XPathNavigator $end : (optional) The XPathNavigator object positioned on the element boundary which the current XPathNavigator will not move past while searching for the following element. @return bool true if the XPathNavigator moved successfully; otherwise false.
[ "Moves", "the", "XPathNavigator", "to", "the", "following", "element", "of", "the", "XPathNodeType", "specified", "to", "the", "boundary", "specified", "in", "document", "order", "." ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L827-L878
25,399
bseddon/XPath20
DOM/DOMXPathNavigator.php
DOMXPathNavigator.MoveToNext
public function MoveToNext( $kind = XPathNodeType::All ) { if ( is_null( $this->domNode ) || is_null( $kind ) /* || ! $this->domNode instanceof \DOMElement */ ) return false; // Create a list of the valid DOM node types based on the $kind value $domNodeTypes = array_keys( array_filter( DOMXPathNavigator::$nodeTypeMap, function( $nodeType ) use( $kind ) { return $kind == XPathNodeType::All || $nodeType == $kind; } ) ); // Take a copy of the dom node $next = $this->domNode; while( ! is_null( $next = $next->nextSibling ) ) { // If the $next node type is valid then store the next node type as the new dom node and return true if ( in_array( $next->nodeType, $domNodeTypes ) ) { $this->domNode = $next; return true; } } return false; }
php
public function MoveToNext( $kind = XPathNodeType::All ) { if ( is_null( $this->domNode ) || is_null( $kind ) /* || ! $this->domNode instanceof \DOMElement */ ) return false; // Create a list of the valid DOM node types based on the $kind value $domNodeTypes = array_keys( array_filter( DOMXPathNavigator::$nodeTypeMap, function( $nodeType ) use( $kind ) { return $kind == XPathNodeType::All || $nodeType == $kind; } ) ); // Take a copy of the dom node $next = $this->domNode; while( ! is_null( $next = $next->nextSibling ) ) { // If the $next node type is valid then store the next node type as the new dom node and return true if ( in_array( $next->nodeType, $domNodeTypes ) ) { $this->domNode = $next; return true; } } return false; }
[ "public", "function", "MoveToNext", "(", "$", "kind", "=", "XPathNodeType", "::", "All", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "domNode", ")", "||", "is_null", "(", "$", "kind", ")", "/* || ! $this->domNode instanceof \\DOMElement */", ")", "return", "false", ";", "// Create a list of the valid DOM node types based on the $kind value\r", "$", "domNodeTypes", "=", "array_keys", "(", "array_filter", "(", "DOMXPathNavigator", "::", "$", "nodeTypeMap", ",", "function", "(", "$", "nodeType", ")", "use", "(", "$", "kind", ")", "{", "return", "$", "kind", "==", "XPathNodeType", "::", "All", "||", "$", "nodeType", "==", "$", "kind", ";", "}", ")", ")", ";", "// Take a copy of the dom node\r", "$", "next", "=", "$", "this", "->", "domNode", ";", "while", "(", "!", "is_null", "(", "$", "next", "=", "$", "next", "->", "nextSibling", ")", ")", "{", "// If the $next node type is valid then store the next node type as the new dom node and return true\r", "if", "(", "in_array", "(", "$", "next", "->", "nodeType", ",", "$", "domNodeTypes", ")", ")", "{", "$", "this", "->", "domNode", "=", "$", "next", ";", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Moves the XPathNavigator to the next sibling node of the current node that matches the XPathNodeType specified. @param XPathNodeType $kind : (optional) The XPathNodeType of the sibling node to move to. @return bool true if the XPathNavigator is successful moving to the next sibling node; otherwise, false if there are no more siblings or if the XPathNavigator is currently positioned on an attribute node. If false, the position of the XPathNavigator is unchanged.
[ "Moves", "the", "XPathNavigator", "to", "the", "next", "sibling", "node", "of", "the", "current", "node", "that", "matches", "the", "XPathNodeType", "specified", "." ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/DOM/DOMXPathNavigator.php#L889-L915