2018-12-10 16:26:57 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models\Oai;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Contains content and structure of a resumption token
|
|
|
|
*/
|
|
|
|
class ResumptionToken
|
|
|
|
{
|
2020-05-07 17:29:18 +00:00
|
|
|
/**
|
|
|
|
* Holds dcoument ids
|
2018-12-10 16:26:57 +00:00
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2020-05-07 17:29:18 +00:00
|
|
|
private $documentIds = array();
|
2018-12-10 16:26:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Holds metadata prefix information
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
private $metadataPrefix = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Holds resumption id (only if token is stored)
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
private $resumptionId = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Holds start postion
|
|
|
|
*
|
|
|
|
* @var integer
|
|
|
|
*/
|
2020-05-07 17:29:18 +00:00
|
|
|
private $startPosition = 0;
|
2018-12-10 16:26:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Holds total amount of document ids
|
|
|
|
*
|
|
|
|
* @var integer
|
|
|
|
*/
|
|
|
|
private $totalIds = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns current holded document ids.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getDocumentIds()
|
|
|
|
{
|
2020-05-07 17:29:18 +00:00
|
|
|
return $this->documentIds;
|
2018-12-10 16:26:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns metadata prefix information.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getMetadataPrefix()
|
|
|
|
{
|
2020-05-07 17:29:18 +00:00
|
|
|
return $this->metadataPrefix;
|
2018-12-10 16:26:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return setted resumption id after successful storing of resumption token.
|
|
|
|
*
|
2020-05-07 17:29:18 +00:00
|
|
|
* @return string
|
2018-12-10 16:26:57 +00:00
|
|
|
*/
|
|
|
|
public function getResumptionId()
|
|
|
|
{
|
2020-05-07 17:29:18 +00:00
|
|
|
return $this->resumptionId;
|
2018-12-10 16:26:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns start position.
|
|
|
|
*
|
|
|
|
* @return in
|
|
|
|
*/
|
|
|
|
public function getStartPosition()
|
|
|
|
{
|
2020-05-07 17:29:18 +00:00
|
|
|
return $this->startPosition;
|
2018-12-10 16:26:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns total number of document ids for this request
|
|
|
|
*
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getTotalIds()
|
|
|
|
{
|
2020-05-07 17:29:18 +00:00
|
|
|
return $this->totalIds;
|
2018-12-10 16:26:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set document ids for this token.
|
|
|
|
*
|
|
|
|
* @param $idsToStore Set of document ids to store.
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function setDocumentIds($idsToStore)
|
|
|
|
{
|
|
|
|
if (false === is_array($idsToStore)) {
|
|
|
|
$idsToStore = array($idsToStore);
|
|
|
|
}
|
|
|
|
|
2020-05-07 17:29:18 +00:00
|
|
|
$this->documentIds = $idsToStore;
|
2018-12-10 16:26:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set metadata prefix information.
|
|
|
|
*
|
|
|
|
* @param string $prefix
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function setMetadataPrefix($prefix)
|
|
|
|
{
|
2020-05-07 17:29:18 +00:00
|
|
|
$this->metadataPrefix = $prefix;
|
2018-12-10 16:26:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set resumption id
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function setResumptionId($resumptionId)
|
|
|
|
{
|
2020-05-07 17:29:18 +00:00
|
|
|
$this->resumptionId = $resumptionId;
|
2018-12-10 16:26:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set postion where to start on next request.
|
|
|
|
*
|
|
|
|
* @param $startPostion Positon where to start on next request
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function setStartPosition($startPosition)
|
|
|
|
{
|
2020-05-07 17:29:18 +00:00
|
|
|
$this->startPosition = (int) $startPosition;
|
2018-12-10 16:26:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set count of document ids for this request.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function setTotalIds($totalIds)
|
|
|
|
{
|
2020-05-07 17:29:18 +00:00
|
|
|
$this->totalIds = (int) $totalIds;
|
2018-12-10 16:26:57 +00:00
|
|
|
}
|
|
|
|
}
|