From 08b8872a2d8d66e31c5540e588fc12c7b906d751 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Mon, 29 Jul 2019 16:45:31 -0400 Subject: [PATCH] Simplify code with null coalescing. --- module/VuFind/src/VuFind/Auth/Manager.php | 25 +++++++---------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/module/VuFind/src/VuFind/Auth/Manager.php b/module/VuFind/src/VuFind/Auth/Manager.php index 131a5fd761e..2722f1dd027 100644 --- a/module/VuFind/src/VuFind/Auth/Manager.php +++ b/module/VuFind/src/VuFind/Auth/Manager.php @@ -143,8 +143,7 @@ class Manager implements \ZfcRbac\Identity\IdentityProviderInterface // Initialize active authentication setting (defaulting to Database // if no setting passed in): - $method = isset($config->Authentication->method) - ? $config->Authentication->method : 'Database'; + $method = $config->Authentication->method ?? 'Database'; $this->legalAuthOptions = [$method]; // mark it as legal $this->setAuthMethod($method); // load it } @@ -206,11 +205,8 @@ class Manager implements \ZfcRbac\Identity\IdentityProviderInterface */ public function supportsRecovery($authMethod = null) { - if ($this->getAuth($authMethod)->supportsPasswordRecovery()) { - return isset($this->config->Authentication->recover_password) - && $this->config->Authentication->recover_password; - } - return false; + return ($this->config->Authentication->recover_password ?? false) + && $this->getAuth($authMethod)->supportsPasswordRecovery(); } /** @@ -223,12 +219,8 @@ class Manager implements \ZfcRbac\Identity\IdentityProviderInterface */ public function supportsPasswordChange($authMethod = null) { - if (isset($this->config->Authentication->change_password) - && $this->config->Authentication->change_password - ) { - return $this->getAuth($authMethod)->supportsPasswordChange(); - } - return false; + return ($this->config->Authentication->change_password ?? false) + && $this->getAuth($authMethod)->supportsPasswordChange(); } /** @@ -357,9 +349,7 @@ class Manager implements \ZfcRbac\Identity\IdentityProviderInterface public function loginEnabled() { // Assume login is enabled unless explicitly turned off: - return isset($this->config->Authentication->hideLogin) - ? !$this->config->Authentication->hideLogin - : true; + return !($this->config->Authentication->hideLogin ?? false); } /** @@ -507,8 +497,7 @@ class Manager implements \ZfcRbac\Identity\IdentityProviderInterface */ public function inPrivacyMode() { - return isset($this->config->Authentication->privacy) - && $this->config->Authentication->privacy; + return $this->config->Authentication->privacy ?? false; } /** -- GitLab