Skip to content
Snippets Groups Projects
Commit 08b8872a authored by Demian Katz's avatar Demian Katz Committed by Robert Lange
Browse files

Simplify code with null coalescing.

parent e3bdc0b3
No related merge requests found
...@@ -143,8 +143,7 @@ class Manager implements \ZfcRbac\Identity\IdentityProviderInterface ...@@ -143,8 +143,7 @@ class Manager implements \ZfcRbac\Identity\IdentityProviderInterface
// Initialize active authentication setting (defaulting to Database // Initialize active authentication setting (defaulting to Database
// if no setting passed in): // if no setting passed in):
$method = isset($config->Authentication->method) $method = $config->Authentication->method ?? 'Database';
? $config->Authentication->method : 'Database';
$this->legalAuthOptions = [$method]; // mark it as legal $this->legalAuthOptions = [$method]; // mark it as legal
$this->setAuthMethod($method); // load it $this->setAuthMethod($method); // load it
} }
...@@ -206,11 +205,8 @@ class Manager implements \ZfcRbac\Identity\IdentityProviderInterface ...@@ -206,11 +205,8 @@ class Manager implements \ZfcRbac\Identity\IdentityProviderInterface
*/ */
public function supportsRecovery($authMethod = null) public function supportsRecovery($authMethod = null)
{ {
if ($this->getAuth($authMethod)->supportsPasswordRecovery()) { return ($this->config->Authentication->recover_password ?? false)
return isset($this->config->Authentication->recover_password) && $this->getAuth($authMethod)->supportsPasswordRecovery();
&& $this->config->Authentication->recover_password;
}
return false;
} }
/** /**
...@@ -223,12 +219,8 @@ class Manager implements \ZfcRbac\Identity\IdentityProviderInterface ...@@ -223,12 +219,8 @@ class Manager implements \ZfcRbac\Identity\IdentityProviderInterface
*/ */
public function supportsPasswordChange($authMethod = null) public function supportsPasswordChange($authMethod = null)
{ {
if (isset($this->config->Authentication->change_password) return ($this->config->Authentication->change_password ?? false)
&& $this->config->Authentication->change_password && $this->getAuth($authMethod)->supportsPasswordChange();
) {
return $this->getAuth($authMethod)->supportsPasswordChange();
}
return false;
} }
/** /**
...@@ -357,9 +349,7 @@ class Manager implements \ZfcRbac\Identity\IdentityProviderInterface ...@@ -357,9 +349,7 @@ class Manager implements \ZfcRbac\Identity\IdentityProviderInterface
public function loginEnabled() public function loginEnabled()
{ {
// Assume login is enabled unless explicitly turned off: // Assume login is enabled unless explicitly turned off:
return isset($this->config->Authentication->hideLogin) return !($this->config->Authentication->hideLogin ?? false);
? !$this->config->Authentication->hideLogin
: true;
} }
/** /**
...@@ -507,8 +497,7 @@ class Manager implements \ZfcRbac\Identity\IdentityProviderInterface ...@@ -507,8 +497,7 @@ class Manager implements \ZfcRbac\Identity\IdentityProviderInterface
*/ */
public function inPrivacyMode() public function inPrivacyMode()
{ {
return isset($this->config->Authentication->privacy) return $this->config->Authentication->privacy ?? false;
&& $this->config->Authentication->privacy;
} }
/** /**
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment