sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
public function put($id, $data)
{
if(!$this->db) {
throw new SagException('No database specified');
}
if(!is_string($id)) {
throw new SagException('put() expected a string for the doc id.');
}
if(!isset($data) || (!is_object($data) && !is_string($data) && !is_array($data))) {
t... | PUT's the data to the document.
@param string $id The document's _id.
@param mixed $data The document, which should have _id and _rev
properties. Can be an object, array, or string.
@return mixed | entailment |
public function post($data, $path = null) {
if(!$this->db) {
throw new SagException('No database specified');
}
if(!isset($data) || (!is_string($data) && !is_object($data) && !is_array($data))) {
throw new SagException('post() needs an object for data.');
}
if(!is_string($data)) {
... | POST's the provided document. When using a SagCache, the created document
and response are not cached.
@param mixed $data The document that you want created. Can be an object,
array, or string.
@param string $path Can be the path to a view or /all_docs. The database
will be prepended to the value.
@return mixed | entailment |
public function bulk($docs, $allOrNothing = false) {
if(!$this->db) {
throw new SagException('No database specified');
}
if(!is_array($docs)) {
throw new SagException('bulk() expects an array for its first argument');
}
if(!is_bool($allOrNothing)) {
throw new SagException('bulk()... | Bulk pushes documents to the database.
This function does not leverage the caching mechanism you specify with
setCache().
@param array $docs An array of the documents you want to be pushed; they
can be JSON strings, objects, or arrays.
@param bool $allOrNothing Whether to treat the transactions as "all or
nothing" or... | entailment |
public function copy($srcID, $dstID, $dstRev = null) {
if(!$this->db) {
throw new SagException('No database specified');
}
if(empty($srcID) || !is_string($srcID)) {
throw new SagException('copy() got an invalid source ID');
}
if(empty($dstID) || !is_string($dstID)) {
throw new Sa... | COPY's the document.
If you are using a SagCache and are copying to an existing destination,
then the result will be cached (ie., what's copied to the /$destID URL).
@param string The _id of the document you're copying.
@param string The _id of the document you're copying to.
@param string The _rev of the document yo... | entailment |
public function setDatabase($db, $createIfNotFound = false) {
if($this->db != $db || $createIfNotFound) {
if(!is_string($db)) {
throw new SagException('setDatabase() expected a string.');
}
$db = urlencode($db);
if($createIfNotFound) {
try {
self::procPacket('HEAD... | Sets which database Sag is going to send all of its database related
communications to (ex., dealing with documents).
When specifying that the database should be created if it doesn't already
exists, this will cause an HTTP GET to be sent to /dbName and
createDatabase($db) if a 404 response is returned. So, only turn ... | entailment |
public function getAllDocs($incDocs = false, $limit = null, $startKey = null, $endKey = null, $keys = null, $descending = false, $skip = 0) {
if(!$this->db) {
throw new SagException('No database specified.');
}
$qry = array();
if($incDocs !== false) {
if(!is_bool($incDocs)) {
throw... | Gets all the documents in the database with _all_docs. Its results will
not be cached by SagCache.
@param bool $incDocs Whether to include the documents or not. Defaults to
false.
@param int $limit Limits the number of documents to return. Must be >= 0,
or null for no limit. Defaults to null (no limit).
@param string ... | entailment |
public function replicate($src, $target, $continuous = false, $createTarget = null, $filter = null, $filterQueryParams = null) {
if(empty($src) || !is_string($src)) {
throw new SagException('replicate() is missing a source to replicate from.');
}
if(empty($target) || !is_string($target)) {
thro... | Starts a replication job between two databases, independently of which
database you set with Sag.
@param string $src The name of the database that you are replicating from.
@param string $target The name of the database that you are replicating
to.
@param bool $continuous Whether to make this a continuous replication ... | entailment |
public function setAttachment($name, $data, $contentType, $docID, $rev = null) {
if(empty($docID)) {
throw new SagException('You need to provide a document ID.');
}
if(empty($name)) {
throw new SagException('You need to provide the attachment\'s name.');
}
if(empty($data)) {
thro... | Create or update attachments on documents by passing in a serialized
version of your attachment (a string).
@param string $name The attachment's name.
@param string $data The attachment's data, in string representation. Ie.,
you need to serialize your attachment.
@param string $contentType The proper Content-Type for ... | entailment |
public function setCookie($key, $value) {
if(!$key || !is_string($key)) {
throw new SagException('Unexpected cookie key.');
}
if($value && !is_string($value)) {
throw new SagException('Unexpected cookie value.');
}
if($value) {
$this->globalCookies[$key] = $value;
}
els... | Sets a global cookie that will overwrite any other internal cookie values
that Sag tries to set. For example, if you set AuthSession and call
login(), then the AuthSession value you specify will overwrite the value
retrieved from the server, so don't set AuthSession while using login().
Setting the value to null will ... | entailment |
public function getCookie($key) {
return (!empty($this->globalCookies[$key])) ? $this->globalCookies[$key] : null;
} | Returns the global cookie as set in setCookie().
@return String The cookie's value or null if not set.
@see setCookie() | entailment |
public function setSSLCert($path) {
if($path !== null) {
if(!is_string($path) || !$path) {
throw new SagException('Invalid file path provided.');
}
if(!is_file($path)) {
throw new SagException('That path does not point to a file.');
}
if(!is_readable($path)) {
... | Provide a path to a file that contains one or more certificates to verify
the CouchDB host with when using SSL. Only applies if you set
useSSL(true).
@param string $path File path to the certificate file. Pass null to unset
the path.
@return Sag Returns $this.
@see useSSL() | entailment |
private function procPacket($method, $url, $data = null, $headers = array()) {
/*
* For now we only data data as strings. Streams and other formats will be
* permitted later.
*/
if($data && !is_string($data)) {
throw new SagException('Unexpected data format. Please report this bug.');
}... | The main driver - does all the socket and protocol work. | entailment |
private function setURLParameter($url, $key, $value) {
$url = parse_url($url);
if(!empty($url['query'])) {
parse_str($url['query'], $params);
}
$params[$key] = $value;
return $url = $url['path'].'?'.http_build_query($params);
} | Takes a URL and k/v combo for a URL parameter, break the query string out
of the URL, and sets the parameter to the k/v pair you pass in. This will
overwrite a paramter's value if it already exists in the URL, or simply
create it if it doesn't already.
@param string $url The URL to run against.
@param string $key The... | entailment |
protected function extractMetaData(ZipArchive $package)
{
// Data holders
$coreProperties = array();
// Read relations and search for core properties
$relations = simplexml_load_string($package->getFromName("_rels/.rels"));
foreach ($relations->Relationship as $rel) {
... | Extract metadata from document
@param ZipArchive $package ZipArchive OpenXML package
@return array Key-value pairs containing document meta data | entailment |
public function send($recipient, $body, $originator = '', $user_ref = null)
{
$this->checkCredentials();
$this->validateRecipient($recipient);
$params = array(
'USERNAME' => $this->username,
'PASSWORD' => $this->password,
'TEXT' => $body,
... | {@inheritDoc} | entailment |
protected function encodeMessage($msg)
{
$encodings = array(
9 => '	',
10 => '
',
13 => '
',
32 => ' ',
34 => '"',
39 => ''',
);
$ret = array();
for ($j = 0; $j < strlen($msg); $j+... | Encodes the message according to doc
@param string $msg
@return string | entailment |
protected function buildGetCreditPayload()
{
$xml = new \SimpleXMLElement(
'<?xml version="1.0" encoding="ISO-8859-1"?>'.
'<!DOCTYPE REQUESTCREDIT SYSTEM "http://127.0.0.1:80/psms/dtd/requestcredit.dtd">'.
'<REQUESTCREDIT></REQUESTCREDIT>'
);
$xml->addAtt... | Constructs valid XML for sending SMS-CR credit request service
@return string | entailment |
protected function buildGetStatusPayload($messageId)
{
$xml = new \SimpleXMLElement(
'<?xml version="1.0" encoding="ISO-8859-1"?>'.
'<!DOCTYPE STATUSREQUEST SYSTEM "http://127.0.0.1:80/psms/dtd/requeststatusv12.dtd">'.
'<STATUSREQUEST VER="1.2"></STATUSREQUEST>'
)... | Constructs valid XML for sending SMS-SR request service
@param string $messageId
@return string | entailment |
protected function buildSendSmsPayload(array $data = array())
{
$xml = new \SimpleXMLElement(
'<?xml version="1.0" encoding="ISO-8859-1"?>'.
'<!DOCTYPE MESSAGE SYSTEM "http://127.0.0.1:80/psms/dtd/messagev12.dtd">'.
'<MESSAGE VER="1.2"></MESSAGE>'
);
$use... | Constructs valid XML for sending SMS-MT message
@param array $data
@return string | entailment |
public function getParameters(array $additionnal_parameters = array())
{
$defaults = array(
// ------------- USER TAG -------------
/*
* User name of the sender of the message.
*/
'USERNAME' => null,
/*
* User password
... | Builds the parameters list to send to the API.
@return array | entailment |
protected function parseSendResponse($result, array $extra_result_data = array())
{
libxml_use_internal_errors(true);
if (false === ($result = simplexml_load_string(trim($result)))) {
throw new Exception\RuntimeException('API response isn\'t a valid XML string');
}
if (n... | Parses the data returned by the API.
@param string $result The raw result string.
@param array $extra_result_data
@return array
@throws Exception if error code found | entailment |
protected function checkForError(\SimpleXMLElement $result)
{
/* -- sample general error --
<?xml version="1.0" encoding="ISO-8859-1"?>
<MESSAGEACK>
<Err Code="65535" Desc="The Specified message does not conform to DTD"/>
</MESSAGEACK>
*/
if (0 !== $result... | @param SimpleXMLElement $result The raw result string.
@return Exception\Exception | entailment |
public static function binary($name, $value)
{
return new self($name, $value, '', true, false, false, true);
} | Constructs a Binary String valued Field that is not tokenized nor indexed,
but is stored in the index, for return with hits.
@param string $name
@param string $value
@param string $encoding
@return Zend_Search_Lucene_Field | entailment |
public static function text($name, $value, $encoding = '')
{
return new self($name, $value, $encoding, true, true, true);
} | Constructs a String-valued Field that is tokenized and indexed,
and is stored in the index, for return with hits. Useful for short text
fields, like "title" or "subject". Term vector will not be stored for this field.
@param string $name
@param string $value
@param string $encoding
@return Zend_Search_Lucene_Field | entailment |
public static function unStored($name, $value, $encoding = '')
{
return new self($name, $value, $encoding, false, true, true);
} | Constructs a String-valued Field that is tokenized and indexed,
but that is not stored in the index.
@param string $name
@param string $value
@param string $encoding
@return Zend_Search_Lucene_Field | entailment |
public function getUtf8Value()
{
if (strcasecmp($this->encoding, 'utf8') == 0
|| strcasecmp($this->encoding, 'utf-8') == 0
) {
return $this->value;
} else {
return (PHP_OS != 'AIX') ? iconv($this->encoding, 'UTF-8', $this->value) : iconv('ISO8859-1... | Get field value in UTF-8 encoding
@return string | entailment |
protected function cleanOriginator($number)
{
// Remove any invalid characters
$ret = preg_replace('/[^a-zA-Z0-9]/', '', (string) $number);
if (preg_match('/[a-zA-Z]/', $number)) {
// Alphanumeric format so make sure it's < 11 chars
$ret = substr($ret, 0, 11);
... | Validate an originator string
If the originator ('from' field) is invalid, some networks may reject
the network whilst stinging you with the financial cost! While this
cannot correct them, it will try its best to correctly format them.
@param string $number The phone number to clean.
@return string The cleaned phone... | entailment |
public function &readBuffer($length) {
if ($length+$this->cursor > strlen($this->rawData)) {
throw new Exception('Buffer underrun at position: '. $this->cursor . '. Trying to fetch '. $length . ' bytes');
return false;
}
$data = substr($this->rawData,... | &readBuffer
@param int $length
@return mixed | entailment |
public function readDouble() {
$double = $this->readBuffer(8);
$testEndian = unpack("C*",pack("S*",256));
$bigEndian = !$testEndian[1]==1;
if ($bigEndian) $double = strrev($double);
$double = unpack("d",$double);
return $... | readDouble
@return float | entailment |
function get($key, $default = null) {
if (!is_string($key)) {
throw new InvalidArgumentException('$key must be a string');
}
if (!isset($this->cache[$key])) {
return $default;
}
list($expire, $value) = $this->cache[$key];
if (!is_null($expire) && ... | 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 set($key, $value, $ttl = null) {
if (!is_string($key)) {
throw new InvalidArgumentException('$key must be a string');
}
if ($ttl instanceof DateInterval) {
$expire = (new DateTime('now'))->add($ttl)->getTimeStamp();
} elseif (is_int($ttl) || ctype_digit(... | Persists data in the cache, uniquely referenced by a key with an
optional expiration TTL time.
@param string $key The key of the item to store.
@param mixed $value The value of the item to store, must
be serializable.
@param null|int|DateInterval $ttl Optional. The TTL value of this ... | entailment |
public function connect($host, $port = null, $ssl = false)
{
$isTls = false;
if ($ssl) {
$ssl = strtolower($ssl);
}
switch ($ssl) {
case 'ssl':
$host = 'ssl://'.$host;
if (!$port) {
$port = 995;
... | Open connection to POP3 server
@param string $host hostname or IP address of POP3 server
@param int|null $port of POP3 server, default is 110 (995 for ssl)
@param string|bool $ssl use 'SSL', 'TLS' or false
@throws \RuntimeException
@return string welcome message | entailment |
public function sendRequest($request)
{
try {
$result = fputs($this->_socket, $request."\r\n");
} catch (\Exception $e) {
}
if (!$result) {
throw new \RuntimeException('send failed - connection closed?'.$e->getMessage());
}
} | Send a request
@param string $request your request without newline
@throws \RuntimeException | entailment |
public function readResponse($multiline = false)
{
try {
$result = fgets($this->_socket);
} catch (\Exception $e) {
}
if (!is_string($result)) {
throw new \RuntimeException('read failed - connection closed?'.$e->getMessage());
}
$result = tr... | read a response
@param bool $multiline response has multiple lines and should be read until "<nl>.<nl>"
@throws \RuntimeException
@return string response | entailment |
public function logout()
{
if ($this->_socket) {
try {
$this->request('QUIT');
} catch (\Exception $e) {
// ignore error - we're closing the socket anyway
}
fclose($this->_socket);
$this->_socket = null;
}
... | End communication with POP3 server (also closes socket) | entailment |
public function login($user, $password, $tryApop = true)
{
if ($tryApop && $this->_timestamp) {
try {
$this->request("APOP $user ".md5($this->_timestamp.$password));
return;
} catch (\Exception $e) {
// ignore
}
}
... | Login to POP3 server. Can use APOP
@param string $user username
@param string $password password
@param bool $tryApop should APOP be tried? | entailment |
private static function _floatToByte($f)
{
// round negatives up to zero
if ($f <= 0.0) {
return 0;
}
// search for appropriate value
$lowIndex = 0;
$highIndex = 255;
while ($highIndex >= $lowIndex) {
// $mid = ($highIndex - $lowIndex)... | Float to byte conversion
@param integer $b
@return float | entailment |
public function idf($input, Zend_Search_Lucene_Interface $reader)
{
if (!is_array($input)) {
return $this->idfFreq($reader->docFreq($input), $reader->count());
} else {
$idf = 0.0;
foreach ($input as $term) {
$idf += $this->idfFreq($reader->docFreq... | Computes a score factor for a simple term or a phrase.
The default implementation is:
return idfFreq(searcher.docFreq(term), searcher.maxDoc());
input - the term in question or array of terms
reader - reader the document collection being searched
Returns a score factor for the term
@param mixed ... | entailment |
private function _parseRichText($is = null)
{
$value = array();
if (isset($is->t)) {
$value[] = (string)$is->t;
} else {
foreach ($is->r as $run) {
$value[] = (string)$run->t;
}
}
return implode('', $value);
} | Parse rich text XML
@param SimpleXMLElement $is
@return string | entailment |
private function _loadDelFile()
{
if ($this->_delGen == -1) {
// There is no delete file for this segment
return null;
} else if ($this->_delGen == 0) {
// It's a segment with pre-2.1 format delete file
// Try to load deletions file
return ... | Load detetions file
Returns bitset or an array depending on bitset extension availability
@return mixed
@throws Zend_Search_Lucene_Exception | entailment |
private function _loadPre21DelFile()
{
require_once 'Zend/Search/Lucene/Exception.php';
try {
// '.del' files always stored in a separate file
// Segment compound is not used
$delFile = $this->_directory->getFileObject($this->_name . '.del');
$byteCou... | Load pre-2.1 detetions file
Returns bitset or an array depending on bitset extension availability
@return mixed
@throws Zend_Search_Lucene_Exception | entailment |
private function _load21DelFile()
{
$delFile = $this->_directory->getFileObject($this->_name . '_' . base_convert($this->_delGen, 10, 36) . '.del');
$format = $delFile->readInt();
if ($format == (int)0xFFFFFFFF) {
if (extension_loaded('bitset')) {
$deletions = b... | Load 2.1+ format detetions file
Returns bitset or an array depending on bitset extension availability
@return mixed | entailment |
public function openCompoundFile($extension, $shareHandler = true)
{
if (($extension == '.fdx' || $extension == '.fdt') && $this->_usesSharedDocStore) {
$fdxFName = $this->_sharedDocStoreOptions['segment'] . '.fdx';
$fdtFName = $this->_sharedDocStoreOptions['segment'] . '.fdt';
... | Opens index file stoted within compound index file
@param string $extension
@param boolean $shareHandler
@throws Zend_Search_Lucene_Exception
@return Zend_Search_Lucene_Storage_File | entailment |
public function compoundFileLength($extension)
{
if (($extension == '.fdx' || $extension == '.fdt') && $this->_usesSharedDocStore) {
$filename = $this->_sharedDocStoreOptions['segment'] . $extension;
if (!$this->_sharedDocStoreOptions['isCompound']) {
return $this... | Get compound file length
@param string $extension
@return integer | entailment |
public function getFieldNum($fieldName)
{
foreach( $this->_fields as $field ) {
if( $field->name == $fieldName ) {
return $field->number;
}
}
return -1;
} | Returns field index or -1 if field is not found
@param string $fieldName
@return integer | entailment |
public function getFields($indexed = false)
{
$result = array();
foreach( $this->_fields as $field ) {
if( (!$indexed) || $field->isIndexed ) {
$result[ $field->name ] = $field->name;
}
}
return $result;
} | Returns array of fields.
if $indexed parameter is true, then returns only indexed fields.
@param boolean $indexed
@return array | entailment |
private function _deletedCount()
{
if ($this->_deleted === null) {
return 0;
}
if (extension_loaded('bitset')) {
return count(bitset_to_array($this->_deleted));
} else {
return count($this->_deleted);
}
} | Returns number of deleted documents.
@return integer | entailment |
private function _getFieldPosition($fieldNum) {
// Treat values which are not in a translation table as a 'direct value'
return isset($this->_fieldsDicPositions[$fieldNum]) ?
$this->_fieldsDicPositions[$fieldNum] : $fieldNum;
} | Get field position in a fields dictionary
@param integer $fieldNum
@return integer | entailment |
private function _loadDictionaryIndex()
{
// Check, if index is already serialized
if ($this->_directory->fileExists($this->_name . '.sti')) {
// Load serialized dictionary index data
$stiFile = $this->_directory->getFileObject($this->_name . '.sti');
$stiFileData... | Load terms dictionary index
@throws Zend_Search_Lucene_Exception | entailment |
public function getTermInfo(Zend_Search_Lucene_Index_Term $term)
{
$termKey = $term->key();
if (isset($this->_termInfoCache[$termKey])) {
$termInfo = $this->_termInfoCache[$termKey];
// Move termInfo to the end of cache
unset($this->_termInfoCache[$termKey]);
... | Scans terms dictionary and returns term info
@param Zend_Search_Lucene_Index_Term $term
@return Zend_Search_Lucene_Index_TermInfo | entailment |
public function termDocs(Zend_Search_Lucene_Index_Term $term, $shift = 0, $docsFilter = null)
{
$termInfo = $this->getTermInfo($term);
if (!$termInfo instanceof Zend_Search_Lucene_Index_TermInfo) {
if ($docsFilter !== null && $docsFilter instanceof Zend_Search_Lucene_Index_DocsFilter)... | Returns IDs of all the documents containing term.
@param Zend_Search_Lucene_Index_Term $term
@param integer $shift
@param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
@return array | entailment |
public function termPositions(Zend_Search_Lucene_Index_Term $term, $shift = 0, $docsFilter = null)
{
$termInfo = $this->getTermInfo($term);
if (!$termInfo instanceof Zend_Search_Lucene_Index_TermInfo) {
if ($docsFilter !== null && $docsFilter instanceof Zend_Search_Lucene_Index_DocsFi... | Returns term positions array.
Result array structure: array(docId => array(pos1, pos2, ...), ...)
@param Zend_Search_Lucene_Index_Term $term
@param integer $shift
@param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
@return Zend_Search_Lucene_Index_TermInfo | entailment |
private function _loadNorm($fieldNum)
{
if ($this->_hasSingleNormFile) {
$normfFile = $this->openCompoundFile('.nrm');
$header = $normfFile->readBytes(3);
$headerFormatVersion = $normfFile->readByte();
if ($header != 'NRM' || $headerFormatVers... | Load normalizatin factors from an index file
@param integer $fieldNum
@throws Zend_Search_Lucene_Exception | entailment |
public function norm($id, $fieldName)
{
$fieldNum = $this->getFieldNum($fieldName);
if ( !($this->_fields[$fieldNum]->isIndexed) ) {
return null;
}
if (!isset($this->_norms[$fieldNum])) {
$this->_loadNorm($fieldNum);
}
return Zend_Search_Luc... | Returns normalization factor for specified documents
@param integer $id
@param string $fieldName
@return float | entailment |
public function normVector($fieldName)
{
$fieldNum = $this->getFieldNum($fieldName);
if ($fieldNum == -1 || !($this->_fields[$fieldNum]->isIndexed)) {
$similarity = Zend_Search_Lucene_Search_Similarity::getDefault();
return str_repeat(chr($similarity->encodeNorm( $similar... | Returns norm vector, encoded in a byte string
@param string $fieldName
@return string | entailment |
public function delete($id)
{
$this->_deletedDirty = true;
if (extension_loaded('bitset')) {
if ($this->_deleted === null) {
$this->_deleted = bitset_empty($id);
}
bitset_incl($this->_deleted, $id);
} else {
if ($this->_deleted... | Deletes a document from the index segment.
$id is an internal document id
@param integer | entailment |
public function isDeleted($id)
{
if ($this->_deleted === null) {
return false;
}
if (extension_loaded('bitset')) {
return bitset_in($this->_deleted, $id);
} else {
return isset($this->_deleted[$id]);
}
} | Checks, that document is deleted
@param integer
@return boolean | entailment |
public function writeChanges()
{
// Get new generation number
$latestDelGen = $this->_detectLatestDelGen();
if (!$this->_deletedDirty) {
// There was no deletions by current process
if ($latestDelGen == $this->_delGen) {
// Delete file hasn't been up... | Write changes if it's necessary.
This method must be invoked only from the Writer _updateSegments() method,
so index Write lock has to be already obtained.
@internal
@throws Zend_Search_Lucene_Exceptions | entailment |
public function resetTermsStream(/** $startId = 0, $mode = self::SM_TERMS_ONLY */)
{
/**
* SegmentInfo->resetTermsStream() method actually takes two optional parameters:
* $startId (default value is 0)
* $mode (default value is self::SM_TERMS_ONLY)
*/
$argList... | Reset terms stream
$startId - id for the fist document
$compact - remove deleted documents
Returns start document id for the next segment
@param integer $startId
@param integer $mode
@throws Zend_Search_Lucene_Exception
@return integer | entailment |
public function skipTo(Zend_Search_Lucene_Index_Term $prefix)
{
if ($this->_termDictionary === null) {
$this->_loadDictionaryIndex();
}
$searchField = $this->getFieldNum($prefix->field);
if ($searchField == -1) {
/**
* Field is not presented in ... | Skip terms stream up to specified term preffix.
Prefix contains fully specified field info and portion of searched term
@param Zend_Search_Lucene_Index_Term $prefix
@throws Zend_Search_Lucene_Exception | entailment |
public function nextTerm()
{
if ($this->_tisFile === null || $this->_termCount == 0) {
$this->_lastTerm = null;
$this->_lastTermInfo = null;
$this->_lastTermPositions = null;
$this->_docMap = null;
// may be necessary fo... | Scans terms dictionary and returns next term
@return Zend_Search_Lucene_Index_Term|null | entailment |
public function closeTermsStream()
{
$this->_tisFile = null;
$this->_frqFile = null;
$this->_prxFile = null;
$this->_lastTerm = null;
$this->_lastTermInfo = null;
$this->_lastTermPositions = null;
$this->_docMap = null;
} | Close terms stream
Should be used for resources clean up if stream is not read up to the end | entailment |
public function logout()
{
if ($this->_mails) {
foreach ($this->_mails as $mail) {
if ($mail['is_deleted']) {
unlink($this->_path.'/'.$mail['file_name']);
}
}
}
} | Закрытие протокола, удаление файлов | entailment |
public function readDir()
{
$files = scandir($this->_path);
foreach ($files as $file) {
$path_info = pathinfo($file);
if ($path_info['extension'] == 'eml') {
$this->_mails[] = [
'is_deleted' => 0,
'file_name' => $file
... | Считывание писем из папки | entailment |
public function getList($id = null)
{
if ($this->_mails) {
if ($id != null && isset($this->_mails[$id])) {
return [filesize($this->_path.'/'.$this->_mails[$id]['file_name'])];
}
$result = [];
foreach ($this->_mails as $mail) {
... | Получение размера писем
@param null|int $id
@return array|null | entailment |
public function delete($id)
{
if ($this->_mails && isset($this->_mails[$id])) {
$this->_mails[$id]['is_deleted'] = true;
}
} | Удаление письма по номеру в списке
@param int $id | entailment |
public function undelete($id = null)
{
if ($this->_mails) {
if ($id != null && isset($this->_mails[$id])) {
$this->_mails[$id]['is_deleted'] = false;
} else {
foreach ($this->_mails as $mail) {
$mail['is_deleted'] = false;
... | Отмена удаления письмо по id или всех писем в списке
@param null|int $id | entailment |
public function top($id)
{
if ($this->_mails && isset($this->_mails[$id])) {
$lines = file($this->_path.'/'.$this->_mails[$id]['file_name']);
// $data = file_get_contents($this->_path.'/'.$this->_mails[$id]['file_name']);
// preg_match(Headers::BOUNDARY_PATTERN, str_replace... | Получение заголовков письма
@param $id
@return null|string | entailment |
public function retrieve($id)
{
if ($this->_mails && isset($this->_mails[$id])) {
return file_get_contents($this->_path.'/'.$this->_mails[$id]['file_name']);
}
return null;
} | Получение всего контента письма
@param $id
@return null|string | entailment |
public function add_field( array $field, $position = 0 ) {
return $this->builder->add_group_field( $this->group_id, $field, $position );
} | {@inheritdoc} | entailment |
public function add($line)
{
$uriParser = new UriParser($line);
$uri = $uriParser->encode();
if (!$uriParser->validate() ||
in_array($uri, $this->sitemaps)
) {
return false;
}
$this->sitemaps[] = $uri;
return true;
} | Add
@param string $line
@return bool | entailment |
public function render(RenderHandler $handler)
{
sort($this->sitemaps);
foreach ($this->sitemaps as $sitemap) {
$handler->add(self::DIRECTIVE_SITEMAP, $sitemap);
}
return true;
} | Render
@param RenderHandler $handler
@return bool | entailment |
public function sendMessage()
{
try {
// First: Send message with given transport
$this->_transport->sendMessage();
// Second: Create a mail instance to store
$mail = $this->getMail();
$mail->updateWithTransport($this->_transport);
$ma... | Send a mail using this transport
@return Base
@throws MailException | entailment |
public function lookup(Request $request)
{
$cacheKey = $this->getCacheKey($request);
$item = $this->cache->getItem($cacheKey);
if (!$item->isHit()) {
return null;
}
$entries = $item->get();
foreach ($entries as $varyKeyResponse => $responseData) {
... | Locates a cached Response for the Request provided.
@param Request $request A Request instance
@return Response|null A Response instance, or null if no cache entry was found | entailment |
public function write(Request $request, Response $response)
{
if (!$response->headers->has('X-Content-Digest')) {
$contentDigest = $this->generateContentDigest($response);
if (false === $this->saveDeferred($contentDigest, $response->getContent())) {
throw new \Runtim... | Writes a cache entry to the store for the given Request and Response.
Existing entries are read and any that match the response are removed. This
method calls write with the new list of cache entries.
@param Request $request A Request instance
@param Response $response A Response instance
@return string The key un... | entailment |
public function invalidate(Request $request)
{
$cacheKey = $this->getCacheKey($request);
$this->cache->deleteItem($cacheKey);
} | Invalidates all cache entries that match the request.
@param Request $request A Request instance | entailment |
public function lock(Request $request)
{
$cacheKey = $this->getCacheKey($request);
if (isset($this->locks[$cacheKey])) {
return false;
}
$this->locks[$cacheKey] = $this->lockFactory
->createLock($cacheKey);
return $this->locks[$cacheKey]->acquire();... | Locks the cache for a given Request.
@param Request $request A Request instance
@return bool|string true if the lock is acquired, the path to the current lock otherwise | entailment |
public function unlock(Request $request)
{
$cacheKey = $this->getCacheKey($request);
if (!isset($this->locks[$cacheKey])) {
return false;
}
try {
$this->locks[$cacheKey]->release();
} catch (LockReleasingException $e) {
return false;
... | Releases the lock for the given Request.
@param Request $request A Request instance
@return bool False if the lock file does not exist or cannot be unlocked, true otherwise | entailment |
public function isLocked(Request $request)
{
$cacheKey = $this->getCacheKey($request);
if (!isset($this->locks[$cacheKey])) {
return false;
}
return $this->locks[$cacheKey]->isAcquired();
} | Returns whether or not a lock exists.
@param Request $request A Request instance
@return bool true if lock exists, false otherwise | entailment |
public function purge($url)
{
$cacheKey = $this->getCacheKey(Request::create($url));
return $this->cache->deleteItem($cacheKey);
} | Purges data for the given URL.
@param string $url A URL
@return bool true if the URL exists and has been purged, false otherwise | entailment |
public function cleanup()
{
try {
foreach ($this->locks as $lock) {
$lock->release();
}
} catch (LockReleasingException $e) {
// noop
} finally {
$this->locks = [];
}
} | Release all locks.
{@inheritdoc} | entailment |
public function invalidateTags(array $tags)
{
if (!$this->cache instanceof TagAwareAdapterInterface) {
throw new \RuntimeException('Cannot invalidate tags on a cache
implementation that does not implement the TagAwareAdapterInterface.');
}
try {
return $t... | The tags are set from the header configured in cache_tags_header.
{@inheritdoc} | entailment |
public function getCacheKey(Request $request)
{
// Strip scheme to treat https and http the same
$uri = $request->getUri();
$uri = substr($uri, \strlen($request->getScheme().'://'));
return 'md'.hash('sha256', $uri);
} | @param Request $request
@return string | entailment |
public function getVaryKey(array $vary, Request $request)
{
if (0 === \count($vary)) {
return self::NON_VARYING_KEY;
}
sort($vary);
$hashData = '';
foreach ($vary as $headerName) {
$hashData .= $headerName.':'.$request->headers->get($headerName);
... | @param array $vary
@param Request $request
@return string | entailment |
private function autoPruneExpiredEntries()
{
if (0 === $this->options['prune_threshold']) {
return;
}
$item = $this->cache->getItem(self::COUNTER_KEY);
$counter = (int) $item->get();
if ($counter > $this->options['prune_threshold']) {
$this->prune();... | Increases a counter every time an item is stored to the cache and then
prunes expired cache entries if a configurable threshold is reached.
This only happens during write operations so cache retrieval is not
slowed down. | entailment |
private function saveDeferred($key, $data, $expiresAfter = null, $tags = [])
{
$item = $this->cache->getItem($key);
$item->set($data);
$item->expiresAfter($expiresAfter);
if (0 !== \count($tags)) {
$item->tag($tags);
}
return $this->cache->saveDeferred($... | @param string $key
@param string $data
@param int $expiresAfter
@param array $tags
@return bool | entailment |
private function restoreResponse(array $cacheData)
{
$body = null;
if (isset($cacheData['headers']['x-content-digest'][0])) {
$item = $this->cache->getItem($cacheData['headers']['x-content-digest'][0]);
if ($item->isHit()) {
$body = $item->get();
... | Restores a Response from the cached data.
@param array $cacheData An array containing the cache data
@return Response|null | entailment |
public function handle()
{
try {
$this->info('LaraAdmin Code Editor installation started...');
$from = base_path('vendor/dwij/laeditor/src/Installs');
$to = base_path();
$this->info('from: '.$from." to: ".$to);
$this->copyFile($from."/resources/views/index.blade.php", $to."/resources/views/la... | Generate Whole structure for /admin
@return mixed | entailment |
private function fileContains($filePath, $text) {
$fileData = file_get_contents($filePath);
if (strpos($fileData, $text) === false ) {
return true;
} else {
return false;
}
} | TODO:Method not working properly | entailment |
public function load(ServiceContainer $container, array $params): void
{
if (!$container instanceof IndexedServiceContainer) {
throw new \InvalidArgumentException(sprintf(
'Container passed from phpspec must implement "%s"!',
IndexedServiceContainer::class
... | {@inheritdoc} | entailment |
public function debug()
{
$query = $this->pdo->prepare(<<<SQL
SELECT *
FROM robotstxt__cache1
WHERE base = :base;
SQL
);
$query->bindValue('base', $this->base, \PDO::PARAM_STR);
$query->execute();
return $query->rowCount() > 0 ? $query->fetch(\PDO::FETCH_ASSOC) : [];
} | Debug - Get raw data
@return array | entailment |
public function client()
{
$query = $this->pdo->prepare(<<<SQL
SELECT
content,
statusCode,
nextUpdate,
effective,
worker,
UNIX_TIMESTAMP()
FROM robotstxt__cache1
WHERE base = :base;
SQL
);
$query->bindValue('base', $this->base, \PDO::PARAM_STR);
$query->execute();
... | Parser client
@return TxtClient
@throws Exceptions\OutOfSyncException
@throws Exceptions\DatabaseException | entailment |
private function markAsActive($workerID = 0)
{
if ($workerID == 0) {
$query = $this->pdo->prepare(<<<SQL
UPDATE robotstxt__cache1
SET worker = NULL
WHERE base = :base AND worker = 0;
SQL
);
$query->bindValue('base', $this->base, \PDO::PARAM_STR);
return $query... | Mark robots.txt as active
@param int|null $workerID
@return bool | entailment |
public function refresh()
{
$client = new UriClient($this->base, $this->curlOptions, $this->byteLimit);
$effective = $client->getEffectiveUri();
if ($effective == $this->base) {
$effective = null;
}
$statusCode = $client->getStatusCode();
$nextUpdate = $cl... | Update the robots.txt
@return UriClient
@throws Exceptions\DatabaseException | entailment |
private function displacePush($nextUpdate)
{
$query = $this->pdo->prepare(<<<SQL
SELECT
validUntil,
UNIX_TIMESTAMP()
FROM robotstxt__cache1
WHERE base = :base;
SQL
);
$query->bindValue('base', $this->base, \PDO::PARAM_STR);
$query->execute();
if ($query->rowCount() > 0) {... | Displace push timestamp
@param int $nextUpdate
@return bool
@throws Exceptions\OutOfSyncException | entailment |
public function invalidate()
{
$query = $this->pdo->prepare(<<<SQL
DELETE FROM robotstxt__cache1
WHERE base = :base;
SQL
);
$query->bindValue('base', $this->base, \PDO::PARAM_STR);
return $query->execute();
} | Invalidate cache
@return bool | entailment |
private function downloadMetadata()
{
Logger::debug($this->logLoc.'Downloading metadata from '.var_export($this->url, true));
$context = ['ssl' => []];
if ($this->sslCAFile !== null) {
$context['ssl']['cafile'] = Config::getCertPath($this->sslCAFile);
Logger::debug($... | Retrieve and parse the metadata.
@return \SAML2\XML\md\EntitiesDescriptor|\SAML2\XML\md\EntityDescriptor|null
The downloaded metadata or NULL if we were unable to download or parse it. | entailment |
public function updateCache()
{
if ($this->updateAttempted) {
return;
}
$this->updateAttempted = true;
$this->metadata = $this->downloadMetadata();
if ($this->metadata === null) {
return;
}
$expires = time() + 24*60*60; // Default exp... | Attempt to update our cache file.
@return void | entailment |
public function getMetadata()
{
if ($this->metadata !== null) {
/* We have already downloaded the metdata. */
return $this->metadata;
}
if (!$this->aggregator->isCacheValid($this->cacheId, $this->cacheTag)) {
$this->updateCache();
/** @psalm-s... | Retrieve the metadata file.
This function will check its cached copy, to see whether it can be used.
@return \SAML2\XML\md\EntityDescriptor|\SAML2\XML\md\EntitiesDescriptor|null The downloaded metadata. | entailment |
public function run()
{
header('HTTP/1.1 200 OK');
header('Content-Type: text/event-stream;charset=UTF-8');
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
header('Pragma: no-cache');
while (1) {
$stats = $this->metricsPoller->getStatsFor... | Serves text/event-stream format | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.