/**
* Retrieves an operator from the available operators.
*
* Throws an AdldapException if no operator is found.
*
* @param string $operator
*
* @throws InvalidQueryOperatorException
*
* @return string
*/
private function validateOperator($operator)
{
$operators = Operator::all();
$key = array_search(strtolower($operator), $operators);
if ($key !== false && array_key_exists($key, $operators)) {
return $operators[$key];
}
$operators = implode(', ', $operators);
$message = "Operator: {$operator} cannot be used in an LDAP query. Available operators are: {$operators}";
throw new InvalidQueryOperatorException($message);
}