From fa74dd6bea94a0aeac71894a96fa3c35ade48f79 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Sun, 8 Apr 2018 08:25:54 -0400
Subject: [PATCH] Code simplification.

---
 module/VuFind/src/VuFind/RecordTab/Factory.php     |  9 ++-------
 module/VuFind/src/VuFind/RecordTab/HoldingsILS.php | 11 +++++------
 2 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/module/VuFind/src/VuFind/RecordTab/Factory.php b/module/VuFind/src/VuFind/RecordTab/Factory.php
index 03b5a91272f..c7853fce8f5 100644
--- a/module/VuFind/src/VuFind/RecordTab/Factory.php
+++ b/module/VuFind/src/VuFind/RecordTab/Factory.php
@@ -145,13 +145,8 @@ class Factory
         // ILS driver specifies no holdings, we need to pass in a connection
         // object:
         $config = $sm->get('VuFind\Config\PluginManager')->get('config');
-        if (isset($config->Site->hideHoldingsTabWhenEmpty)
-            && $config->Site->hideHoldingsTabWhenEmpty
-        ) {
-            $catalog = $sm->get('VuFind\ILS\Connection');
-        } else {
-            $catalog = false;
-        }
+        $catalog = ($config->Site->hideHoldingsTabWhenEmpty ?? false)
+            ? $sm->get('VuFind\ILS\Connection') : null;
         return new HoldingsILS($catalog);
     }
 
diff --git a/module/VuFind/src/VuFind/RecordTab/HoldingsILS.php b/module/VuFind/src/VuFind/RecordTab/HoldingsILS.php
index 459598251cd..bb0108143d8 100644
--- a/module/VuFind/src/VuFind/RecordTab/HoldingsILS.php
+++ b/module/VuFind/src/VuFind/RecordTab/HoldingsILS.php
@@ -39,9 +39,9 @@ namespace VuFind\RecordTab;
 class HoldingsILS extends AbstractBase
 {
     /**
-     * ILS connection (or false if not applicable)
+     * ILS connection (or null if not applicable)
      *
-     * @param \VuFind\ILS\Connection|bool
+     * @param \VuFind\ILS\Connection
      */
     protected $catalog;
 
@@ -49,12 +49,11 @@ class HoldingsILS extends AbstractBase
      * Constructor
      *
      * @param \VuFind\ILS\Connection|bool $catalog ILS connection to use to check
-     * for holdings before displaying the tab; set to false if no check is needed
+     * for holdings before displaying the tab; set to null if no check is needed
      */
-    public function __construct($catalog)
+    public function __construct(\VuFind\ILS\Connection $catalog = null)
     {
-        $this->catalog = ($catalog && $catalog instanceof \VuFind\ILS\Connection)
-            ? $catalog : false;
+        $this->catalog = $catalog;
     }
 
     /**
-- 
GitLab