sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
public function writeByte($byte)
{
// We do not need to check if file position points to the end of "file".
// Only append operation is supported now
$this->_data .= chr($byte);
$this->_position = strlen($this->_data);
return 1;
} | Writes a byte to the end of the file.
@param integer $byte | entailment |
public function readBytes($num)
{
$returnValue = substr($this->_data, $this->_position, $num);
$this->_position += $num;
return $returnValue;
} | Read num bytes from the current position in the file
and advances the file pointer.
@param integer $num
@return string | entailment |
public function writeBytes($data, $num=null)
{
// We do not need to check if file position points to the end of "file".
// Only append operation is supported now
if ($num !== null) {
$this->_data .= substr($data, 0, $num);
} else {
$this->_data .= $data;
... | Writes num bytes of data (all, if $num===null) to the end
of the string.
@param string $data
@param integer $num | entailment |
public function readInt()
{
$str = substr($this->_data, $this->_position, 4);
$this->_position += 4;
return ord($str[0]) << 24 |
ord($str[1]) << 16 |
ord($str[2]) << 8 |
ord($str[3]);
} | Reads an integer from the current position in the file
and advances the file pointer.
@return integer | entailment |
public function writeInt($value)
{
// We do not need to check if file position points to the end of "file".
// Only append operation is supported now
settype($value, 'integer');
$this->_data .= chr($value>>24 & 0xFF) .
chr($value>>16 & 0xFF) .
... | Writes an integer to the end of file.
@param integer $value | entailment |
public function readLong()
{
/**
* Check, that we work in 64-bit mode.
* fseek() uses long for offset. Thus, largest index segment file size in 32bit mode is 2Gb
*/
if (PHP_INT_SIZE > 4) {
$str = substr($this->_data, $this->_position, 8);
$this->_po... | Returns a long integer from the current position in the file
and advances the file pointer.
@return integer
@throws Zend_Search_Lucene_Exception | entailment |
public function writeLong($value)
{
// We do not need to check if file position points to the end of "file".
// Only append operation is supported now
/**
* Check, that we work in 64-bit mode.
* fseek() and ftell() use long for offset. Thus, largest index segment file size... | Writes long integer to the end of file
@param integer $value
@throws Zend_Search_Lucene_Exception | entailment |
public function readVInt()
{
$nextByte = ord($this->_data[$this->_position++]);
$val = $nextByte & 0x7F;
for ($shift=7; ($nextByte & 0x80) != 0; $shift += 7) {
$nextByte = ord($this->_data[$this->_position++]);
$val |= ($nextByte & 0x7F) << $shift;
}
... | Returns a variable-length integer from the current
position in the file and advances the file pointer.
@return integer | entailment |
public function writeVInt($value)
{
// We do not need to check if file position points to the end of "file".
// Only append operation is supported now
settype($value, 'integer');
while ($value > 0x7F) {
$this->_data .= chr(($value & 0x7F)|0x80);
$value >>= 7;... | Writes a variable-length integer to the end of file.
@param integer $value | entailment |
public function readString()
{
$strlen = $this->readVInt();
if ($strlen == 0) {
return '';
} else {
/**
* This implementation supports only Basic Multilingual Plane
* (BMP) characters (from 0x0000 to 0xFFFF) and doesn't support
*... | Reads a string from the current position in the file
and advances the file pointer.
@return string | entailment |
public function readBinary()
{
$length = $this->readVInt();
$returnValue = substr($this->_data, $this->_position, $length);
$this->_position += $length;
return $returnValue;
} | Reads binary data from the current position in the file
and advances the file pointer.
@return string | entailment |
public function send($recipient, $body, $originator = '')
{
if (null == $this->client_id) {
throw new InvalidCredentialsException('No API credentials provided');
}
return parent::send($recipient, $body, $originator);
} | {@inheritDoc} | entailment |
protected function _less($termsStream1, $termsStream2)
{
return strcmp($termsStream1->currentTerm()->key(), $termsStream2->currentTerm()->key()) < 0;
} | Compare elements
Returns true, if $termsStream1 is "less" than $termsStream2; else otherwise
@param mixed $termsStream1
@param mixed $termsStream2
@return boolean | entailment |
public function register()
{
$this->mergeConfigFrom(__DIR__ . '/config/settings.php', 'settings');
$this->app->singleton('settings', function ($app)
{
$config = $app->config->get('settings', require __DIR__ . '/config/settings.php');
return new DatabaseRepository(
$app['db'],
new CacheRepository(... | Register the service provider.
@return void | entailment |
public function getStatus()
{
if (null === $this->username || null === $this->password) {
throw new Exception\InvalidCredentialsException('No API credentials provided');
}
$res = $this->getAdapter()->getContent(self::SMS_STATUS_URL, 'POST', $headers = array(), $this->getParamete... | Retrieves the queued delivery receipts
@return array | entailment |
public function send($recipient, $body, $originator = '', $user_ref = null)
{
if (null === $this->username || null === $this->password) {
throw new Exception\InvalidCredentialsException('No API credentials provided');
}
$params = $this->getParameters(array(
'DA' => $... | {@inheritDoc} | entailment |
protected function getParameters(array $additionnal_parameters = array())
{
return array_filter(
array_merge(array(
/*
* -- system type
* Must be set to value: H
*/
'S' => 'H',
/*
... | Builds the parameters list to send to the API.
@return array | entailment |
protected function parseStatusResults($result, array $extra_result_data = array())
{
$result = trim($result);
$this->checkForUnrecoverableError($result);
return $this->checkForStatusResult($result);
} | Parses the data returned by the API for a "status" request.
@param string $result The raw result string.
@param array $extra_result_data
@return array | entailment |
protected function parseSendResults($result, array $extra_result_data = array())
{
$result = trim($result);
$this->checkForUnrecoverableError($result);
if (!$this->isMessageSent($result)) {
return array_merge($this->getDefaults(), $extra_result_data);
}
// The ... | Parses the data returned by the API for a "send" request.
@param string $result The raw result string.
@param array $extra_result_data
@return array | entailment |
function get($key, $default = null) {
if (!is_string($key)) {
throw new InvalidArgumentException('$key must be a string');
}
$result = $this->memcached->get($key);
if ($result === false && $this->memcached->getResultCode() === \Memcached::RES_NOTFOUND) {
return $... | Fetches a value from the cache.
@param string $key The unique key of this item in the cache.
@param mixed $default Default value to return if the key does not exist.
@throws \Psr\SimpleCache\InvalidArgumentException
MUST be thrown if the $key string is not a legal value.
@return mixed The value of the item from ... | entailment |
function has($key) {
if (!is_string($key)) {
throw new InvalidArgumentException('$key must be a string');
}
$result = $this->memcached->get($key);
if ($result === false && $this->memcached->getResultCode() === \Memcached::RES_NOTFOUND) {
return false;
}
... | Determines whether an item is present in the cache.
NOTE: It is recommended that has() is only to be used for cache warming
type purposes and not to be used within your live applications operations
for get/set, as this method is subject to a race condition where your
has() will return true and immediately after, anoth... | entailment |
function getMultiple($keys, $default = null) {
if ($keys instanceof Traversable) {
$keys = iterator_to_array($keys);
} elseif (!is_array($keys)) {
throw new InvalidArgumentException('$keys must be iterable');
}
$result = $this->memcached->getMulti($keys);
... | Obtains multiple cache items by their unique keys.
This particular implementation returns its result as a generator.
@param iterable $keys A list of keys that can obtained in a single
operation.
@param mixed $default Default value to return for keys that do not
exist.
@throws \Psr\SimpleCache\InvalidArgumentExce... | entailment |
function setMultiple($values, $ttl = null) {
if ($values instanceof Traversable) {
$values = iterator_to_array($values);
} elseif (!is_array($values)) {
throw new InvalidArgumentException('$values must be iterable');
}
if ($ttl instanceof DateInterval) {
... | Persists a set of key => value pairs in the cache, with an optional TTL.
@param iterable $values A list of key => value pairs for a
multiple-set operation.
@param null|int|DateInterval $ttl Optional. The TTL value of this
item. If no value is sent and the
driver supports TTL then the library
may set a ... | entailment |
function deleteMultiple($keys) {
if ($keys instanceof Traversable) {
$keys = iterator_to_array($keys);
} elseif (!is_array($keys)) {
throw new InvalidArgumentException('$keys must be iterable');
}
$this->memcached->deleteMulti($keys);
} | Deletes multiple cache items in a single operation.
@param iterable $keys A list of string-based keys to be deleted.
@throws \Psr\SimpleCache\InvalidArgumentException
MUST be thrown if $keys is neither an array nor a Traversable,
or if any of the $keys are not a legal value.
@return bool True if the items were succes... | entailment |
public function setResponse($target,$responsetype,$data) {
switch($responsetype) {
case SabreAMF_Const::R_RESULT :
$target = $target.='/onResult';
break;
case SabreAMF_Const::R_STATUS :
$target = $ta... | setResponse
Send a response back to the client (based on a request you got through getRequests)
@param string $target This parameter should contain the same as the 'response' item you got through getRequests. This connects the request to the response
@param int $responsetype Set as either SabreAMF_Const::R_RESULT or ... | entailment |
public function sendResponse() {
header('Content-Type: ' . SabreAMF_Const::MIMETYPE);
$this->amfResponse->setEncoding($this->amfRequest->getEncoding());
$this->amfResponse->serialize($this->amfOutputStream);
echo($this->amfOutputStream->getRawData());
} | sendResponse
Sends the responses back to the client. Call this after you answered all the requests with setResponse
@return void | entailment |
public function addHeader($name,$required,$data) {
$this->amfResponse->addHeader(array('name'=>$name,'required'=>$required==true,'data'=>$data));
} | addHeader
Add a header to the server response
@param string $name
@param bool $required
@param mixed $data
@return void | entailment |
static public function setInputString($string) {
if (!(is_string($string) && strlen($string) > 0))
throw new SabreAMF_InvalidAMFException();
self::$dataInputStream = null;
self::$dataInputData = $string;
return true;
} | setInputString
Returns the true/false depended on wheater the string was accepted.
That a string is accepted by this method, does NOT mean that it is a valid AMF request.
@param string $string New input string
@author Asbjørn Sloth Tønnesen <asbjorn@lila.io>
@return bool | entailment |
protected function readInput() {
if (is_null(self::$dataInputStream)) return self::$dataInputData;
$data = file_get_contents(self::$dataInputStream);
if (!$data) throw new SabreAMF_InvalidAMFException();
return $data;
} | readInput
Reads the input from stdin unless it has been overwritten
with setInputFile or setInputString.
@author Asbjørn Sloth Tønnesen <asbjorn@lila.io>
@return string Binary string containing the AMF data | entailment |
public function normalize(Zend_Search_Lucene_Analysis_Token $token)
{
foreach ($this->_filters as $filter) {
$token = $filter->normalize($token);
// resulting token can be null if the filter removes it
if ($token === null) {
return null;
}
... | Apply filters to the token. Can return null when the token was removed.
@param Zend_Search_Lucene_Analysis_Token $token
@return Zend_Search_Lucene_Analysis_Token | entailment |
public function withAddedInterceptor(string $name, array $functions): self
{
if (!isset($this->interceptors[$name])) {
$this->interceptors[$name] = [];
}
$this->interceptors[$name] = array_merge($this->interceptors[$name], $functions);
return $this;
} | Add a function to the interceptor
@param string $name
@param callable|array $functions
@return self|$this | entailment |
public function removeInterceptor(string $name): self
{
if (isset($this->interceptors[$name])) {
unset($this->interceptors[$name]);
}
return $this;
} | Remove the interceptor
@param string $name
@return self|$this | entailment |
public function callInterceptor(string $name, ...$arguments)
{
if (!empty($this->interceptors[$name])) {
foreach ($this->interceptors[$name] as $function) {
$ret = Helper::call($function, ...$arguments);
if ($ret !== null) {
return $ret;
... | Call the interceptor
@param string $name
@param array ...$arguments
@return mixed | entailment |
public function prepare(array $query): array
{
if (isset($query['WHERE']) && sizeof($query['WHERE']) > 1) {
$where = $query['WHERE'];
$query['WHERE'] = [[
'expr_type' => 'bracket_expression',
'base_expr' => '',
'sub_tree' => $where,
]];
foreach ($where as $where_data) {
$query['WHERE'][... | In case query contains a more complicated query, place it within brackets: (<complicated_expr>) | entailment |
public static function parse($strQuery, $encoding = null)
{
self::_getInstance();
// Reset FSM if previous parse operation didn't return it into a correct state
self::$_instance->reset();
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
try {
i... | Parses a query string
@param string $strQuery
@param string $encoding
@return Zend_Search_Lucene_Search_Query
@throws Zend_Search_Lucene_Search_QueryParserException | entailment |
public function addTermEntry()
{
include_once 'Zend/Search/Lucene/Search/QueryEntry/Term.php';
$entry = new Zend_Search_Lucene_Search_QueryEntry_Term($this->_currentToken->text, $this->_context->getField());
$this->_context->addEntry($entry);
} | Add term to a query | entailment |
public function addPhraseEntry()
{
include_once 'Zend/Search/Lucene/Search/QueryEntry/Phrase.php';
$entry = new Zend_Search_Lucene_Search_QueryEntry_Phrase($this->_currentToken->text, $this->_context->getField());
$this->_context->addEntry($entry);
} | Add phrase to a query | entailment |
public function processModifierParameter()
{
if ($this->_lastToken === null) {
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw new Zend_Search_Lucene_Search_QueryParserException('Lexeme modifier parameter must follow lexeme modifier. Char position 0.');
... | Process modifier parameter
@throws Zend_Search_Lucene_Exception | entailment |
public function subqueryStart()
{
include_once 'Zend/Search/Lucene/Search/QueryParserContext.php';
$this->_contextStack[] = $this->_context;
$this->_context = new Zend_Search_Lucene_Search_QueryParserContext($this->_encoding, $this->_context->getField());
} | Start subquery | entailment |
public function subqueryEnd()
{
if (count($this->_contextStack) == 0) {
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw new Zend_Search_Lucene_Search_QueryParserException('Syntax Error: mismatched parentheses, every opening must have closing. Char position ' ... | End subquery | entailment |
public function openedRQLastTerm()
{
$tokens = Zend_Search_Lucene_Analysis_Analyzer::getDefault()->tokenize($this->_rqFirstTerm, $this->_encoding);
if (count($tokens) > 1) {
include_once 'Zend/Search/Lucene/Search/QueryParserException.php';
throw new Zend_Search_Lucene_Search... | Process last range query term (opened interval)
@throws Zend_Search_Lucene_Search_QueryParserException | entailment |
public function rewrite(Zend_Search_Lucene_Interface $index)
{
if ($this->_field === null) {
include_once 'Zend/Search/Lucene/Search/Query/Boolean.php';
$query = new Zend_Search_Lucene_Search_Query_Boolean();
$hasInsignificantSubqueries = false;
include_once... | Re-write query into primitive queries in the context of specified index
@param Zend_Search_Lucene_Interface $index
@return Zend_Search_Lucene_Search_Query | entailment |
protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter)
{
/**
* Skip fields detection. We don't need it, since we expect all fields presented in the HTML body and don't differentiate them
*/
/**
* Skip exact term matching recognition, keyword fields hig... | Query specific matches highlighting
@param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting) | entailment |
protected function cached(string $key, Closure $dataGetter)
{
if ($this->cacheRepository->has($key)) {
return $this->cacheRepository->get($key);
}
$result = $dataGetter();
$this->cacheRepository->put($key, $result, $this->cacheTimeout);
return $result;
} | Get data from cache.
If it not exists in cache got it in repository and store in cache.
@param string $key Key to find data in cache
@param Closure $dataGetter Function to get data in original repository
@return mixed | entailment |
public function findOrFail($id): Model
{
$result = $this->cachedFind($id);
if (!$result) {
throw new ModelNotFoundException($this, "{$this->repository->getModelClass()} with ID=$id was not found");
}
return $result;
} | {@inheritdoc} | entailment |
public function findWhere(array $fieldValues): ?Model
{
$key = $this->prefix . ":find:" . md5(serialize($fieldValues));
return $this->cached($key, function () use ($fieldValues) {
return $this->repository->findWhere($fieldValues);
});
} | {@inheritdoc} | entailment |
public function save(Model $model): Model
{
$result = $this->repository->save($model);
$this->invalidate($model);
return $result;
} | {@inheritdoc} | entailment |
public function delete(Model $model): void
{
$this->repository->delete($model);
$this->invalidate($model);
} | {@inheritdoc} | entailment |
public function getWhere(array $fieldValues): Collection
{
$key = $this->prefix . ":get:" . md5(serialize($fieldValues));
return $this->cached($key, function () use ($fieldValues) {
return $this->repository->getWhere($fieldValues);
});
} | {@inheritdoc} | entailment |
public function getPage(PagingInfo $paging, array $fieldValues = []): LengthAwarePaginator
{
$key = $this->prefix . ":page:" . md5(serialize($paging->toArray()) . serialize($fieldValues));
return $this->cached($key, function () use ($paging, $fieldValues) {
return $this->repository->getP... | {@inheritdoc} | entailment |
public function getCursorPage(CursorRequest $cursor, array $fieldValues = []): CursorResult
{
$key = $this->prefix . ":page:" . md5(serialize($cursor->toArray()) . serialize($fieldValues));
return $this->cached($key, function () use ($cursor, $fieldValues) {
return $this->repository->get... | {@inheritdoc} | entailment |
private function find($id): ?Model
{
try {
return $this->repository->findOrFail($id);
} catch (ModelNotFoundException $exception) {
return null;
}
} | Find model in original repository.
@param string|int id Id to find
@return Model|null
@throws RepositoryException | entailment |
protected function invalidate(Model $model): void
{
$key = $this->prefix . ":" . $model->getKey();
if ($this->cacheRepository->has($key)) {
$this->cacheRepository->forget($key);
}
$this->cacheRepository->forget("$this->prefix.:all");
} | Invalidate model in cache.
@param Model $model Model to invalidate
@return void
@throws InvalidArgumentException | entailment |
public function getWith(
array $with,
array $withCounts = [],
array $where = [],
?SortOptions $sortOptions = null
): Collection {
$key = $this->prefix . ":get:" . md5(serialize($with) . serialize($withCounts) . serialize($where));
return $this->cached($key, function (... | {@inheritdoc} | entailment |
public function count(array $fieldValues = []): int
{
$key = $this->prefix . ":all:count";
return $this->cached($key, function () use ($fieldValues) {
return $this->repository->count($fieldValues);
});
} | {@inheritdoc} | entailment |
public function setMax(string $key, int $max_size = -1): int
{
$is_exist = !$this->init($key, $max_size);
if ($is_exist && $this->resource_map[$key] instanceof Channel) {
$current_max = $this->status_map[$key]['max'];
$this->status_map[$key]['max'] = $max_size;
if... | expend will create the new chan
@param string $key
@param int $max_size
@return int do what | entailment |
public static function mkdirs($dir, $mode = 0777, $recursive = true)
{
if (($dir === null) || $dir === '') {
return false;
}
if (is_dir($dir) || $dir === '/') {
return true;
}
if (self::mkdirs(dirname($dir), $mode, $recursive)) {
return mkd... | Utility function to recursive directory creation
@param string $dir
@param integer $mode
@param boolean $recursive
@return boolean | entailment |
public function fileList()
{
$result = array();
$dirContent = opendir($this->_dirPath);
while (($file = readdir($dirContent)) !== false) {
if (($file == '..')||($file == '.')) { continue;
}
if(!is_dir($this->_dirPath . '/' . $file) ) {
... | Returns an array of strings, one for each file in the directory.
@return array | entailment |
public function createFile($filename)
{
if (isset($this->_fileHandlers[$filename])) {
$this->_fileHandlers[$filename]->close();
}
unset($this->_fileHandlers[$filename]);
include_once 'Zend/Search/Lucene/Storage/File/Filesystem.php';
$this->_fileHandlers[$filename]... | Creates a new, empty file in the directory with the given $filename.
@param string $filename
@return Zend_Search_Lucene_Storage_File
@throws Zend_Search_Lucene_Exception | entailment |
public function deleteFile($filename)
{
if (isset($this->_fileHandlers[$filename])) {
$this->_fileHandlers[$filename]->close();
}
unset($this->_fileHandlers[$filename]);
global $php_errormsg;
$trackErrors = ini_get('track_errors'); ini_set('track_errors', '1');
... | Removes an existing $filename in the directory.
@param string $filename
@return void
@throws Zend_Search_Lucene_Exception | entailment |
public function purgeFile($filename)
{
if (isset($this->_fileHandlers[$filename])) {
$this->_fileHandlers[$filename]->close();
}
unset($this->_fileHandlers[$filename]);
} | Purge file if it's cached by directory object
Method is used to prevent 'too many open files' error
@param string $filename
@return void | entailment |
public function fileExists($filename)
{
return isset($this->_fileHandlers[$filename]) ||
file_exists($this->_dirPath . '/' . $filename);
} | Returns true if a file with the given $filename exists.
@param string $filename
@return boolean | entailment |
public function fileLength($filename)
{
if (isset($this->_fileHandlers[$filename])) {
return $this->_fileHandlers[$filename]->size();
}
return filesize($this->_dirPath .'/'. $filename);
} | Returns the length of a $filename in the directory.
@param string $filename
@return integer | entailment |
public function renameFile($from, $to)
{
global $php_errormsg;
if (isset($this->_fileHandlers[$from])) {
$this->_fileHandlers[$from]->close();
}
unset($this->_fileHandlers[$from]);
if (isset($this->_fileHandlers[$to])) {
$this->_fileHandlers[$to]->cl... | Renames an existing file in the directory.
@param string $from
@param string $to
@return void
@throws Zend_Search_Lucene_Exception | entailment |
public function getFileObject($filename, $shareHandler = true)
{
$fullFilename = $this->_dirPath . '/' . $filename;
include_once 'Zend/Search/Lucene/Storage/File/Filesystem.php';
if (!$shareHandler) {
return new Zend_Search_Lucene_Storage_File_Filesystem($fullFilename);
... | Returns a Zend_Search_Lucene_Storage_File object for a given $filename in the directory.
If $shareHandler option is true, then file handler can be shared between File Object
requests. It speed-ups performance, but makes problems with file position.
Shared handler are good for short atomic requests.
Non-shared handlers... | entailment |
public function up()
{
Schema::connection(config('settings.db_connection'))->create(config('settings.db_table'), function (Blueprint $table)
{
$table->string('setting_key')->index()->unique();
$table->binary('setting_value')->nullable();
});
} | Run the migrations.
@return void | entailment |
private function _retrieveNodeText(DOMNode $node, &$text)
{
if ($node->nodeType == XML_TEXT_NODE) {
$text .= $node->nodeValue;
if(!in_array($node->parentNode->tagName, $this->_inlineTags)) {
$text .= ' ';
}
} else if ($node->nodeType == XML_ELEMENT... | Get node text
We should exclude scripts, which may be not included into comment tags, CDATA sections,
@param DOMNode $node
@param string &$text | entailment |
public static function loadHTML($data, $storeContent = false, $defaultEncoding = '')
{
return new Zend_Search_Lucene_Document_Html($data, false, $storeContent, $defaultEncoding);
} | Load HTML document from a string
@param string $data
@param boolean $storeContent
@param string $defaultEncoding HTML encoding, is used if it's not specified using Content-type HTTP-EQUIV meta tag.
@return Zend_Search_Lucene_Document_Html | entailment |
public static function loadHTMLFile($file, $storeContent = false, $defaultEncoding = '')
{
return new Zend_Search_Lucene_Document_Html($file, true, $storeContent, $defaultEncoding);
} | Load HTML document from a file
@param string $file
@param boolean $storeContent
@param string $defaultEncoding HTML encoding, is used if it's not specified using Content-type HTTP-EQUIV meta tag.
@return Zend_Search_Lucene_Document_Html | entailment |
protected function _highlightTextNode(DOMText $node, $wordsToHighlight, $callback, $params)
{
/**
* Zend_Search_Lucene_Analysis_Analyzer
*/
include_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
$analyzer = Zend_Search_Lucene_Analysis_Analyzer::getDefault();
$analyzer->setInput(... | Highlight text in text node
@param DOMText $node
@param array $wordsToHighlight
@param callback $callback Callback method, used to transform (highlighting) text.
@param array $params Array of additionall callback parameters (first non-optional parameter is a text to transform)
@throws Zend... | entailment |
protected function _highlightNodeRecursive(DOMNode $contextNode, $wordsToHighlight, $callback, $params)
{
$textNodes = array();
if (!$contextNode->hasChildNodes()) {
return;
}
foreach ($contextNode->childNodes as $childNode) {
if ($childNode->nodeType == XML... | highlight words in content of the specified node
@param DOMNode $contextNode
@param array $wordsToHighlight
@param callback $callback Callback method, used to transform (highlighting) text.
@param array $params Array of additionall callback parameters (first non-optional parameter is a text to... | entailment |
public function highlightExtended($words, $callback, $params = array())
{
/**
* Zend_Search_Lucene_Analysis_Analyzer
*/
include_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
if (!is_array($words)) {
$words = array($words);
}
$wordsToHighlightList = array();... | Highlight text using specified View helper or callback function.
@param string|array $words Words to highlight. Words could be organized using the array or string.
@param callback $callback Callback method, used to transform (highlighting) text.
@param array $params Array of additionall callback par... | entailment |
public function getHtmlBody()
{
$xpath = new DOMXPath($this->_doc);
$bodyNodes = $xpath->query('/html/body')->item(0)->childNodes;
$outputFragments = array();
for ($count = 0; $count < $bodyNodes->length; $count++) {
$outputFragments[] = $this->_doc->saveXML($bodyNodes->... | Get HTML body
@return string | entailment |
public function rewrite(Zend_Search_Lucene_Interface $index)
{
if ($this->_field === null) {
include_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php';
$query = new Zend_Search_Lucene_Search_Query_MultiTerm();
$query->setBoost($this->getBoost());
$hasInsig... | Re-write query into primitive queries in the context of specified index
@param Zend_Search_Lucene_Interface $index
@return Zend_Search_Lucene_Search_Query | entailment |
protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter)
{
/**
* Skip fields detection. We don't need it, since we expect all fields presented in the HTML body and don't differentiate them
*/
/**
* Skip exact term matching recognition, keyword fields hig... | Query specific matches highlighting
@param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting) | entailment |
private function _calculateMaxDistance($prefixLength, $termLength, $length)
{
$this->_maxDistances[$length] = (int) ((1 - $this->_minimumSimilarity)*(min($termLength, $length) + $prefixLength));
return $this->_maxDistances[$length];
} | Calculate maximum distance for specified word length
@param integer $prefixLength
@param integer $termLength
@param integer $length
@return integer | entailment |
public function rewrite(Zend_Search_Lucene_Interface $index)
{
$this->_matches = array();
$this->_scores = array();
$this->_termKeys = array();
if ($this->_term->field === null) {
// Search through all fields
$fields = $index->getFieldNames(true /* indexed... | Re-write query into primitive queries in the context of specified index
@param Zend_Search_Lucene_Interface $index
@return Zend_Search_Lucene_Search_Query
@throws Zend_Search_Lucene_Exception | entailment |
protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter)
{
$words = array();
include_once 'Zend/Search/Lucene/Index/Term.php';
$prefix = Zend_Search_Lucene_Index_Term::getPrefix($this->_term->text, $this->_prefixLength);
$prefixByt... | Query specific matches highlighting
@param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting) | entailment |
public function send($recipient, $body, $originator = '')
{
$message = new Sms();
$message->fromArray(array(
'recipient' => $recipient,
'body' => $body,
'originator' => $originator,
'status' => ResultInterface::STATUS_QUEUED,
... | {@inheritdoc} | entailment |
public function send($recipient, $body, $originator = '')
{
if (null === $this->accountSid || null === $this->authToken) {
throw new Exception\InvalidCredentialsException('No API credentials provided');
}
if (empty($originator)) {
throw new Exception\InvalidArgumentE... | {@inheritDoc} | entailment |
protected function parseResults($result, array $extra_result_data = array())
{
$data = json_decode($result, true);
$sms_data = array();
// there was an error
if (empty($data['sid']) || !empty($data['message'])) {
return array_merge($this->getDefaults(), $extra_result_dat... | Parse the data returned by the API.
@param string $result The raw result string.
@return array | entailment |
public function upgrade(
ModuleDataSetupInterface $setup,
ModuleContextInterface $context
) {
$setup->startSetup();
/** @var CustomerSetup $customerSetup */
$customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);
if (version_compare($context->getV... | {@inheritdoc} | entailment |
public function deserialize(VisitorInterface $visitor, $data, array $type)
{
if ($data === null) {
return null;
}
// Return enum if exists:
$class = $type['params'][0] ?? null;
if (class_exists($class) && isset(class_parents($class)[Enum::class])) {
r... | @param VisitorInterface $visitor
@param mixed $data
@param array $type
@throws \Paillechat\Enum\Exception\EnumException
@return Enum | entailment |
public function serialize(VisitorInterface $visitor, Enum $enum, array $type, Context $context)
{
$valueType = $type['params'][1] ?? 'string';
switch ($valueType) {
case 'string':
return $visitor->visitString($enum->getValue(), $type, $context);
case 'integer'... | @param VisitorInterface $visitor
@param Enum $enum
@param array $type
@param Context $context
@throws \LogicException
@return mixed | entailment |
public static function init(array $config)
{
if (empty($config['storage']) || ($config['storage'] != self::FILE && $config['storage'] != self::POP3)) {
throw new \InvalidArgumentException('need at least type in params');
}
$className = __NAMESPACE__.'\\'.$config['storage'];
... | @param array $config
@return StorageInterface | entailment |
public function readAMFData($settype = null,$newscope = false) {
if ($newscope) $this->refList = array();
if (is_null($settype)) {
$settype = $this->stream->readByte();
}
switch ($settype) {
case SabreAMF_AMF0_Const::DT_NUMBER : return... | readAMFData
@param int $settype
@param bool $newscope
@return mixed | entailment |
public function readObject() {
$object = array();
$this->refList[] =& $object;
while (true) {
$key = $this->readString();
$vartype = $this->stream->readByte();
if ($vartype==SabreAMF_AMF0_Const::DT_OBJECTTERM) break;
$o... | readObject
@return object | entailment |
public function readReference() {
$refId = $this->stream->readInt();
if (isset($this->refList[$refId])) {
return $this->refList[$refId];
} else {
throw new Exception('Invalid reference offset: ' . $refId);
return false;
... | readReference
@return object | entailment |
public function readArray() {
$length = $this->stream->readLong();
$arr = array();
$this->refList[]&=$arr;
while($length--) $arr[] = $this->readAMFData();
return $arr;
} | readArray
@return array | entailment |
public function readTypedObject() {
$classname = $this->readString();
$isMapped = false;
if ($localClassname = $this->getLocalClassName($classname)) {
$rObject = new $localClassname();
$isMapped = true;
} else {
$rObject ... | readTypedObject
@return object | entailment |
public function reset()
{
$this->_position = 0;
if ($this->_input === null) {
return;
}
// convert input into ascii
if (PHP_OS != 'AIX') {
$this->_input = iconv($this->_encoding, 'ASCII//TRANSLIT', $this->_input);
}
$this->_encoding =... | Reset token stream | entailment |
public function nextToken()
{
if ($this->_input === null) {
return null;
}
do {
if (! preg_match('/[a-zA-Z0-9]+/', $this->_input, $match, PREG_OFFSET_CAPTURE, $this->_position)) {
// It covers both cases a) there are no matches (preg_match(...) === 0)... | Tokenization stream API
Get next token
Returns null at the end of stream
@return Zend_Search_Lucene_Analysis_Token|null | entailment |
public function install(
SchemaSetupInterface $setup,
ModuleContextInterface $context
) {
$installer = $setup;
$installer->startSetup();
$setup->endSetup();
} | {@inheritdoc} | entailment |
public static function createIndex(Zend_Search_Lucene_Storage_Directory $directory, $generation, $nameCount)
{
if ($generation == 0) {
// Create index in pre-2.1 mode
foreach ($directory->fileList() as $file) {
if ($file == 'deletable'
|| $file ==... | Create empty index
@param Zend_Search_Lucene_Storage_Directory $directory
@param integer $generation
@param integer $nameCount | entailment |
public function addDocument(Zend_Search_Lucene_Document $document)
{
/**
* Zend_Search_Lucene_Index_SegmentWriter_DocumentWriter
*/
include_once 'Zend/Search/Lucene/Index/SegmentWriter/DocumentWriter.php';
if ($this->_currentSegment === null) {
$this->_currentSegment =
... | Adds a document to this index.
@param Zend_Search_Lucene_Document $document | entailment |
private function _hasAnythingToMerge()
{
$segmentSizes = array();
foreach ($this->_segmentInfos as $segName => $segmentInfo) {
$segmentSizes[$segName] = $segmentInfo->count();
}
$mergePool = array();
$poolSize = 0;
$sizeToMerge = $this->maxBufferedDo... | Check if we have anything to merge
@return boolean | entailment |
private function _maybeMergeSegments()
{
if (Zend_Search_Lucene_LockManager::obtainOptimizationLock($this->_directory) === false) {
return;
}
if (!$this->_hasAnythingToMerge()) {
Zend_Search_Lucene_LockManager::releaseOptimizationLock($this->_directory);
... | Merge segments if necessary | entailment |
private function _mergeSegments($segments)
{
$newName = $this->_newSegmentName();
/**
* Zend_Search_Lucene_Index_SegmentMerger
*/
include_once 'Zend/Search/Lucene/Index/SegmentMerger.php';
$merger = new Zend_Search_Lucene_Index_SegmentMerger(
$this->_directory,
... | Merge specified segments
$segments is an array of SegmentInfo objects
@param array $segments | entailment |
private function _updateSegments()
{
// Get an exclusive index lock
Zend_Search_Lucene_LockManager::obtainWriteLock($this->_directory);
// Write down changes for the segments
foreach ($this->_segmentInfos as $segInfo) {
$segInfo->writeChanges();
}
$gene... | Update segments file by adding current segment to a list
@throws Zend_Search_Lucene_Exception | entailment |
public function commit()
{
if ($this->_currentSegment !== null) {
$newSegment = $this->_currentSegment->close();
if ($newSegment !== null) {
$this->_newSegments[$newSegment->getName()] = $newSegment;
}
$this->_currentSegment = null;
}
... | Commit current changes | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.