Skip to content

Commit dc12a41

Browse files
committed
Leverage the match expression
1 parent d4abb0e commit dc12a41

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

Adapter/ExtLdap/Query.php

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,12 @@ public function execute(): CollectionInterface
7575
$this->results = [];
7676
$con = $this->connection->getResource();
7777

78-
switch ($this->options['scope']) {
79-
case static::SCOPE_BASE:
80-
$func = 'ldap_read';
81-
break;
82-
case static::SCOPE_ONE:
83-
$func = 'ldap_list';
84-
break;
85-
case static::SCOPE_SUB:
86-
$func = 'ldap_search';
87-
break;
88-
default:
89-
throw new LdapException(sprintf('Could not search in scope "%s".', $this->options['scope']));
90-
}
78+
$func = match ($this->options['scope']) {
79+
static::SCOPE_BASE => 'ldap_read',
80+
static::SCOPE_ONE => 'ldap_list',
81+
static::SCOPE_SUB => 'ldap_search',
82+
default => throw new LdapException(sprintf('Could not search in scope "%s".', $this->options['scope'])),
83+
};
9184

9285
$itemsLeft = $maxItems = $this->options['maxItems'];
9386
$pageSize = $this->options['pageSize'];

0 commit comments

Comments
 (0)