Fix Codacy "Unused Code" Pattern

This commit is contained in:
Sebastian Meyer 2017-10-15 17:51:27 +02:00
parent b7570a2418
commit aa9748799a
1 changed files with 6 additions and 8 deletions

View File

@ -90,16 +90,14 @@ class OAI2Server {
} }
public function ListMetadataFormats() { public function ListMetadataFormats() {
$identifier = '';
foreach ($this->args as $argument => $value) { foreach ($this->args as $argument => $value) {
if ($argument != 'identifier') { if ($argument != 'identifier') {
$this->errors[] = new OAI2Exception('badArgument'); $this->errors[] = new OAI2Exception('badArgument');
} else {
$identifier = $value;
} }
} }
if (isset($this->args['identifier'])) {
$identifier = $this->args['identifier'];
} else {
$identifier = '';
}
if (empty($this->errors)) { if (empty($this->errors)) {
try { try {
if ($formats = call_user_func($this->listMetadataFormatsCallback, $identifier)) { if ($formats = call_user_func($this->listMetadataFormatsCallback, $identifier)) {
@ -143,7 +141,7 @@ class OAI2Server {
try { try {
if ($record = call_user_func($this->getRecordCallback, $this->args['identifier'], $this->args['metadataPrefix'])) { if ($record = call_user_func($this->getRecordCallback, $this->args['identifier'], $this->args['metadataPrefix'])) {
$cur_record = $this->response->addToVerbNode('record'); $cur_record = $this->response->addToVerbNode('record');
$cur_header = $this->response->createHeader($record['identifier'], $this->formatDatestamp($record['timestamp']), $record['deleted'], $cur_record); $this->response->createHeader($record['identifier'], $this->formatDatestamp($record['timestamp']), $record['deleted'], $cur_record);
if (!$record['deleted']) { if (!$record['deleted']) {
$this->addMetadata($cur_record, $record['metadata']); $this->addMetadata($cur_record, $record['metadata']);
} }
@ -217,7 +215,7 @@ class OAI2Server {
if ($this->verb == 'ListRecords') { // for ListIdentifiers, only headers will be returned. if ($this->verb == 'ListRecords') { // for ListIdentifiers, only headers will be returned.
$cur_record = $this->response->addToVerbNode('record'); $cur_record = $this->response->addToVerbNode('record');
} }
$cur_header = $this->response->createHeader($record['identifier'], $this->formatDatestamp($record['timestamp']), $record['deleted'], $cur_record); $this->response->createHeader($record['identifier'], $this->formatDatestamp($record['timestamp']), $record['deleted'], $cur_record);
if (!$record['deleted'] && $this->verb == 'ListRecords') { // for ListIdentifiers, only headers will be returned. if (!$record['deleted'] && $this->verb == 'ListRecords') { // for ListIdentifiers, only headers will be returned.
$this->addMetadata($cur_record, $record['metadata']); $this->addMetadata($cur_record, $record['metadata']);
} }
@ -227,7 +225,7 @@ class OAI2Server {
$deliveredRecords += $maxItems; $deliveredRecords += $maxItems;
$restoken = $this->createResumptionToken($deliveredRecords); $restoken = $this->createResumptionToken($deliveredRecords);
$expirationDatetime = gmstrftime('%Y-%m-%dT%TZ', time()+$this->token_valid); $expirationDatetime = gmstrftime('%Y-%m-%dT%TZ', time()+$this->token_valid);
} elseif (isset($args['resumptionToken'])) { } elseif (isset($this->args['resumptionToken'])) {
// Last delivery, return empty ResumptionToken // Last delivery, return empty ResumptionToken
$restoken = null; $restoken = null;
$expirationDatetime = null; $expirationDatetime = null;