diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/BrowZine/Response/RecordCollection.php b/module/VuFindSearch/src/VuFindSearch/Backend/BrowZine/Response/RecordCollection.php index 533b90b89d6106825104b9ebcbcd8f33ff4ab59d..0e2dad1b9523a9ba48dcf7beb152d873a28067d4 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/BrowZine/Response/RecordCollection.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/BrowZine/Response/RecordCollection.php @@ -68,8 +68,7 @@ class RecordCollection extends AbstractRecordCollection */ public function getTotal() { - return isset($this->response['recordCount']) - ? $this->response['recordCount'] : 0; + return $this->response['recordCount'] ?? 0; } /** @@ -90,7 +89,6 @@ class RecordCollection extends AbstractRecordCollection */ public function getOffset() { - return isset($this->response['offset']) - ? $this->response['offset'] : 0; + return $this->response['offset'] ?? 0; } } diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Backend.php b/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Backend.php index e22d9da23123fe5fe9898c316cb4bb333a161662..a0d643fbbd3d8a1bbef65621679c44e8234745a7 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Backend.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Backend.php @@ -70,21 +70,21 @@ class Backend extends AbstractBackend * * @var string */ - protected $userName = null; + protected $userName; /** * Password for EBSCO EDS API account if using UID Authentication * * @var string */ - protected $password = null; + protected $password; /** * Profile for EBSCO EDS API account (may be overridden) * * @var string */ - protected $profile = null; + protected $profile; /** * Default profile for EBSCO EDS API account (taken from initial config and @@ -92,21 +92,21 @@ class Backend extends AbstractBackend * * @var string */ - protected $defaultProfile = null; + protected $defaultProfile; /** * Whether or not to use IP Authentication for communication with the EDS API * * @var bool */ - protected $ipAuth = false; + protected $ipAuth; /** * Organization EDS API requests are being made for * * @var string */ - protected $orgId = null; + protected $orgId; /** * Vufind Authentication manager @@ -158,21 +158,11 @@ class Backend extends AbstractBackend $this->isGuest = $isGuest; // Extract key values from configuration: - if (isset($config->EBSCO_Account->user_name)) { - $this->userName = $config->EBSCO_Account->user_name; - } - if (isset($config->EBSCO_Account->password)) { - $this->password = $config->EBSCO_Account->password; - } - if (isset($config->EBSCO_Account->ip_auth)) { - $this->ipAuth = $config->EBSCO_Account->ip_auth; - } - if (isset($config->EBSCO_Account->profile)) { - $this->profile = $config->EBSCO_Account->profile; - } - if (isset($config->EBSCO_Account->organization_id)) { - $this->orgId = $config->EBSCO_Account->organization_id; - } + $this->userName = $config->EBSCO_Account->user_name ?? null; + $this->password = $config->EBSCO_Account->password ?? null; + $this->ipAuth = $config->EBSCO_Account->ip_auth ?? false; + $this->profile = $config->EBSCO_Account->profile ?? null; + $this->orgId = $config->EBSCO_Account->organization_id ?? null; // Save default profile value, since profile property may be overriden: $this->defaultProfile = $this->profile; diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Response/RecordCollection.php b/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Response/RecordCollection.php index 1bcf50be8b406d73a6ec6ce76500b842bff9a6e1..778455ef588fc5aa8ca24135d7e1f9a18ee989fc 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Response/RecordCollection.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Response/RecordCollection.php @@ -68,14 +68,7 @@ class RecordCollection extends AbstractRecordCollection */ public function getTotal() { - $totalHits = 0; - if (isset($this->response['SearchResult']) - && isset($this->response['SearchResult']['Statistics']) - && isset($this->response['SearchResult']['Statistics']['TotalHits']) - ) { - $totalHits = $this->response['SearchResult']['Statistics']['TotalHits']; - } - return $totalHits; + return $this->response['SearchResult']['Statistics']['TotalHits'] ?? 0; } /** @@ -85,9 +78,7 @@ class RecordCollection extends AbstractRecordCollection */ public function getRawFacets() { - return isset($this->response['SearchResult']) - && isset($this->response['SearchResult']['AvailableFacets']) - ? $this->response['SearchResult']['AvailableFacets'] : []; + return $this->response['SearchResult']['AvailableFacets'] ?? []; } /** @@ -98,9 +89,7 @@ class RecordCollection extends AbstractRecordCollection public function getFacets() { $vufindFacetList = []; - $facets = isset($this->response['SearchResult']) - && isset($this->response['SearchResult']['AvailableFacets']) - ? $this->response['SearchResult']['AvailableFacets'] : []; + $facets = $this->response['SearchResult']['AvailableFacets'] ?? []; foreach ($facets as $facet) { $vufindFacet['displayName'] = $facet['Id']; $vufindFacet['displayText'] = $facet['Label']; diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Response/RecordCollectionFactory.php b/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Response/RecordCollectionFactory.php index 17ecf8d0992165b1d15c2d44f661bb081dd9e106..577e8558e53988b8a1be6773987af5a1ccaf9fa7 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Response/RecordCollectionFactory.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/EDS/Response/RecordCollectionFactory.php @@ -92,17 +92,10 @@ class RecordCollectionFactory implements RecordCollectionFactoryInterface ); } $collection = new $this->collectionClass($response); - //obtain path to records - $records = []; - if (isset($response['SearchResult']) - && isset($response['SearchResult']['Data']) - && isset($response['SearchResult']['Data']['Records']) - ) { - // Format of the search response - $records = $response['SearchResult']['Data']['Records']; - } elseif (isset($response['Records'])) { // Format of the retrieve response - $records = $response['Records']; - } + // Obtain path to records -- first try format of the search response, + // then try format of the retrieve response, then give up with empty array. + $records = $response['SearchResult']['Data']['Records'] + ?? $response['Records'] ?? []; foreach ($records as $record) { $collection->add(call_user_func($this->recordFactory, $record)); diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/EIT/Response/XML/RecordCollection.php b/module/VuFindSearch/src/VuFindSearch/Backend/EIT/Response/XML/RecordCollection.php index 817462b11894f23efce8a5a9add7df0a8f8ef8d6..61afca4f70d30dd17501e390d3c5ee6330465edd 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/EIT/Response/XML/RecordCollection.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/EIT/Response/XML/RecordCollection.php @@ -70,7 +70,7 @@ class RecordCollection extends AbstractRecordCollection */ public function getTotal() { - return isset($this->response['total']) ? $this->response['total'] : 0; + return $this->response['total'] ?? 0; } /** @@ -90,6 +90,6 @@ class RecordCollection extends AbstractRecordCollection */ public function getOffset() { - return isset($this->response['offset']) ? $this->response['offset'] : 0; + return $this->response['offset'] ?? 0; } } diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/LibGuides/Response/RecordCollection.php b/module/VuFindSearch/src/VuFindSearch/Backend/LibGuides/Response/RecordCollection.php index 247c6c045166a2641d91de18d4e35bbb76274db8..e95c61f4ea57f323e6128c8c1f9dcbd39c9c8e1a 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/LibGuides/Response/RecordCollection.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/LibGuides/Response/RecordCollection.php @@ -68,8 +68,7 @@ class RecordCollection extends AbstractRecordCollection */ public function getTotal() { - return isset($this->response['recordCount']) - ? $this->response['recordCount'] : 0; + return $this->response['recordCount'] ?? 0; } /** @@ -90,7 +89,6 @@ class RecordCollection extends AbstractRecordCollection */ public function getOffset() { - return isset($this->response['offset']) - ? $this->response['offset'] : 0; + return $this->response['offset'] ?? 0; } } diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Pazpar2/Backend.php b/module/VuFindSearch/src/VuFindSearch/Backend/Pazpar2/Backend.php index 61f782743cad0f2a98f42c8e5773c956c4a2782c..9b84ab2c70add6d204d8d68fb188fe028253427c 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Pazpar2/Backend.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Pazpar2/Backend.php @@ -160,7 +160,7 @@ class Backend extends AbstractBackend ); $response = $this->connector->show($showParams); - $hits = isset($response->hit) ? $response->hit : []; + $hits = $response->hit ?? []; $collection = $this->createRecordCollection( $hits, intval($response->merged), $offset ); diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Primo/Response/RecordCollection.php b/module/VuFindSearch/src/VuFindSearch/Backend/Primo/Response/RecordCollection.php index 7fa90f450c40bd37c59624b0502e9b383f6e1a1b..58ca36264968ecd2fcefc71f508d49c86143fbc9 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Primo/Response/RecordCollection.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Primo/Response/RecordCollection.php @@ -68,8 +68,7 @@ class RecordCollection extends AbstractRecordCollection */ public function getTotal() { - return isset($this->response['recordCount']) - ? $this->response['recordCount'] : 0; + return $this->response['recordCount'] ?? 0; } /** @@ -79,8 +78,7 @@ class RecordCollection extends AbstractRecordCollection */ public function getFacets() { - return isset($this->response['facets']) - ? $this->response['facets'] : []; + return $this->response['facets'] ?? []; } /** @@ -92,8 +90,7 @@ class RecordCollection extends AbstractRecordCollection { $page = isset($this->response['query']['pageNumber']) ? $this->response['query']['pageNumber'] - 1 : 0; - $size = isset($this->response['query']['pageSize']) - ? $this->response['query']['pageSize'] : 0; + $size = $this->response['query']['pageSize'] ?? 0; return $page * $size; } } diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Response/Json/Record.php b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Response/Json/Record.php index c7031a42fbbbb742c83170f33732b54ce704e70b..0855407285403df28c2843fe10f1e558f7f9bd30 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Response/Json/Record.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Response/Json/Record.php @@ -101,6 +101,6 @@ class Record implements RecordInterface */ public function __get($name) { - return isset($this->fields[$name]) ? $this->fields[$name] : null; + return $this->fields[$name] ?? null; } } diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Response/Json/RecordCollection.php b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Response/Json/RecordCollection.php index bebfe7a7baccc5c1c5579f07cc00b663a0639d2f..7ab8c7ae4e7e542553983b929ab6efdf71c5d450 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Response/Json/RecordCollection.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Solr/Response/Json/RecordCollection.php @@ -135,8 +135,7 @@ class RecordCollection extends AbstractRecordCollection */ public function getGroups() { - return isset($this->response['grouped']) - ? $this->response['grouped'] : []; + return $this->response['grouped'] ?? []; } /** @@ -146,8 +145,7 @@ class RecordCollection extends AbstractRecordCollection */ public function getHighlighting() { - return isset($this->response['highlighting']) - ? $this->response['highlighting'] : []; + return $this->response['highlighting'] ?? []; } /** @@ -157,8 +155,7 @@ class RecordCollection extends AbstractRecordCollection */ protected function getSolrParameters() { - return isset($this->response['responseHeader']['params']) - ? $this->response['responseHeader']['params'] : []; + return $this->response['responseHeader']['params'] ?? []; } /** @@ -179,7 +176,6 @@ class RecordCollection extends AbstractRecordCollection */ protected function getRawSpellcheckSuggestions() { - return isset($this->response['spellcheck']['suggestions']) - ? $this->response['spellcheck']['suggestions'] : []; + return $this->response['spellcheck']['suggestions'] ?? []; } } diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/Summon/Response/RecordCollection.php b/module/VuFindSearch/src/VuFindSearch/Backend/Summon/Response/RecordCollection.php index 65d0598260f7d45cf136e9bdbeddb6f255ce6c3d..4f2e0716361944bb323dd85d4027f9821cfa39c8 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/Summon/Response/RecordCollection.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/Summon/Response/RecordCollection.php @@ -62,8 +62,7 @@ class RecordCollection extends AbstractRecordCollection // Determine the offset: $page = isset($this->response['query']['pageNumber']) ? $this->response['query']['pageNumber'] - 1 : 0; - $size = isset($this->response['query']['pageSize']) - ? $this->response['query']['pageSize'] : 0; + $size = $this->response['query']['pageSize'] ?? 0; $this->offset = $page * $size; $this->rewind(); @@ -76,8 +75,7 @@ class RecordCollection extends AbstractRecordCollection */ public function getTotal() { - return isset($this->response['recordCount']) - ? $this->response['recordCount'] : 0; + return $this->response['recordCount'] ?? 0; } /** @@ -87,8 +85,7 @@ class RecordCollection extends AbstractRecordCollection */ public function getFacets() { - return isset($this->response['facetFields']) - ? $this->response['facetFields'] : []; + return $this->response['facetFields'] ?? []; } /** @@ -98,12 +95,8 @@ class RecordCollection extends AbstractRecordCollection */ public function getSpellcheck() { - if (isset($this->response['didYouMeanSuggestions']) - && is_array($this->response['didYouMeanSuggestions']) - ) { - return $this->response['didYouMeanSuggestions']; - } - return []; + return is_array($this->response['didYouMeanSuggestions'] ?? null) + ? $this->response['didYouMeanSuggestions'] : []; } /** @@ -113,8 +106,7 @@ class RecordCollection extends AbstractRecordCollection */ public function getBestBets() { - return isset($this->response['recommendationLists']['bestBet']) - ? $this->response['recommendationLists']['bestBet'] : false; + return $this->response['recommendationLists']['bestBet'] ?? false; } /** @@ -124,8 +116,7 @@ class RecordCollection extends AbstractRecordCollection */ public function getDatabaseRecommendations() { - return isset($this->response['recommendationLists']['database']) - ? $this->response['recommendationLists']['database'] : false; + return $this->response['recommendationLists']['database'] ?? false; } /** @@ -135,7 +126,6 @@ class RecordCollection extends AbstractRecordCollection */ public function getTopicRecommendations() { - return isset($this->response['topicRecommendations']) - ? $this->response['topicRecommendations'] : false; + return $this->response['topicRecommendations'] ?? false; } } diff --git a/module/VuFindSearch/src/VuFindSearch/Backend/WorldCat/Connector.php b/module/VuFindSearch/src/VuFindSearch/Backend/WorldCat/Connector.php index 13c9eed6c796ad21c624a42e612a935d8e27ce4e..46d47bccaa701752403ba9e9c49ff166fbdc11f6 100644 --- a/module/VuFindSearch/src/VuFindSearch/Backend/WorldCat/Connector.php +++ b/module/VuFindSearch/src/VuFindSearch/Backend/WorldCat/Connector.php @@ -156,7 +156,7 @@ class Connector extends \VuFindSearch\Backend\SRU\Connector $response = $this->call('POST', $params->getArrayCopy(), false); $xml = simplexml_load_string($response); - $docs = isset($xml->records->record) ? $xml->records->record : []; + $docs = $xml->records->record ?? []; $finalDocs = []; foreach ($docs as $doc) { $finalDocs[] = $doc->recordData->asXML(); diff --git a/module/VuFindSearch/src/VuFindSearch/ParamBag.php b/module/VuFindSearch/src/VuFindSearch/ParamBag.php index 8aed52dcda71d7cc47e101d1b2e7202b6277751f..8921caf2a120aff7e8c7a3e68039600325a99275 100644 --- a/module/VuFindSearch/src/VuFindSearch/ParamBag.php +++ b/module/VuFindSearch/src/VuFindSearch/ParamBag.php @@ -73,7 +73,7 @@ class ParamBag implements \Countable */ public function get($name) { - return isset($this->params[$name]) ? $this->params[$name] : null; + return $this->params[$name] ?? null; } /** diff --git a/module/VuFindSearch/src/VuFindSearch/Response/AbstractRecordCollection.php b/module/VuFindSearch/src/VuFindSearch/Response/AbstractRecordCollection.php index b8c48657f1b614be3ca5ca8ee703f6f57a699c5b..45b973533820c51772758bcbb4dea66dbffacbd8 100644 --- a/module/VuFindSearch/src/VuFindSearch/Response/AbstractRecordCollection.php +++ b/module/VuFindSearch/src/VuFindSearch/Response/AbstractRecordCollection.php @@ -94,7 +94,7 @@ abstract class AbstractRecordCollection implements RecordCollectionInterface */ public function first() { - return isset($this->records[0]) ? $this->records[0] : null; + return $this->records[0] ?? null; } /**