Fix Codacy Code Style Issues

This commit is contained in:
Sebastian Meyer 2020-01-16 15:36:33 +01:00
parent 4a6ce98df4
commit 30e3d8bf69
3 changed files with 13 additions and 11 deletions

View File

@ -44,7 +44,7 @@ class OAI2Response {
if (!empty($this->verb)) {
$request->setAttribute('verb', $this->verb);
}
foreach($request_args as $key => $value) {
foreach ($request_args as $key => $value) {
$request->setAttribute($key, $value);
}
}
@ -91,14 +91,14 @@ class OAI2Response {
* Otherwise it will be attached to the desired node defined in $add_to_node.
*/
public function createHeader($identifier, $timestamp, $deleted = false, $add_to_node = null) {
if(is_null($add_to_node)) {
if (is_null($add_to_node)) {
$header_node = $this->addToVerbNode('header');
} else {
$header_node = $this->addChild($add_to_node, 'header');
}
$this->addChild($header_node, 'identifier', $identifier);
$this->addChild($header_node, 'datestamp', $timestamp);
if($deleted) {
if ($deleted) {
$header_node->setAttribute('status', 'deleted');
}
return $header_node;
@ -114,7 +114,7 @@ class OAI2Response {
*/
public function createResumptionToken($token, $expirationdatetime, $num_rows, $cursor = null) {
$resump_node = $this->addChild($this->verbNode, 'resumptionToken', $token);
if(isset($expirationdatetime)) {
if (isset($expirationdatetime)) {
$resump_node->setAttribute('expirationDate', $expirationdatetime);
}
$resump_node->setAttribute('completeListSize', $num_rows);

View File

@ -63,7 +63,7 @@ class OAI2Server {
}
$errorResponse = new OAI2Response($this->uri, $this->verb, $this->args);
$oai_node = $errorResponse->doc->documentElement;
foreach($this->errors as $e) {
foreach ($this->errors as $e) {
$node = $errorResponse->addChild($oai_node, 'error', $e->getMessage());
$node->setAttribute('code', $e->getOAI2Code());
}
@ -72,11 +72,11 @@ class OAI2Server {
public function Identify() {
if (count($this->args) > 0) {
foreach($this->args as $key => $val) {
foreach ($this->args as $key => $val) {
$this->errors[] = new OAI2Exception('badArgument');
}
} else {
foreach($this->identifyResponse as $key => $val) {
foreach ($this->identifyResponse as $key => $val) {
$this->response->addToVerbNode($key, $val);
}
}
@ -94,7 +94,7 @@ class OAI2Server {
if (empty($this->errors)) {
try {
if ($formats = call_user_func($this->listMetadataFormatsCallback, $identifier)) {
foreach($formats as $key => $val) {
foreach ($formats as $key => $val) {
$cmf = $this->response->addToVerbNode('metadataFormat');
$this->response->addChild($cmf, 'metadataPrefix', $key);
$this->response->addChild($cmf, 'schema', $val['schema']);
@ -195,7 +195,7 @@ class OAI2Server {
}
}
if (isset($this->args['set'])) {
$this->errors[] = new OAI2Exception('noSetHierarchy');
$this->errors[] = new OAI2Exception('noSetHierarchy');
}
}
if (empty($this->errors)) {
@ -244,7 +244,7 @@ class OAI2Server {
list($usec, $sec) = explode(' ', microtime());
$token = ((int)($usec*1000) + (int)($sec*1000)).'_'.$metadataPrefix;
$file = fopen($this->token_prefix.$token, 'w');
if($file == false) {
if ($file == false) {
exit('Cannot write resumption token. Writing permission needs to be changed.');
}
fputs($file, $deliveredRecords.'#');

View File

@ -18,7 +18,9 @@
*/
// Make this script only executable via commandline interface!
if (php_sapi_name() !== 'cli') exit;
if (php_sapi_name() !== 'cli') {
exit;
}
require_once './Configuration/Main.php';