Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Commit e30762f

Browse files
committed
Use more ternary logic.
1 parent 0699cba commit e30762f

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

src/Traits/ImportsUsers.php

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ protected function getModelFromAdldap(User $user, $password)
4343
$model = $this->createModel()->newQuery()->where([$key => $username])->first();
4444

4545
// Create the model instance of it isn't found.
46-
if (!$model instanceof Model) {
47-
$model = $this->createModel();
48-
}
46+
$model = ($model instanceof Model ? $model : $this->createModel());
4947

5048
// Set the username and password in case
5149
// of changes in active directory.
@@ -58,9 +56,8 @@ protected function getModelFromAdldap(User $user, $password)
5856
// attributes on the model.
5957
$model = $this->syncModelFromAdldap($user, $model);
6058

61-
if ($this->getBindUserToModel()) {
62-
$model = $this->bindAdldapToModel($user, $model);
63-
}
59+
// Bind the Adldap model to the elqoquent model if configured.
60+
$model = ($this->getBindUserToModel() ? $this->bindAdldapToModel($user, $model) : $model);
6461

6562
return $model;
6663
}
@@ -185,11 +182,9 @@ protected function handleAttributeRetrieval(User $user, $field)
185182
} else {
186183
$value = $user->{$field};
187184

188-
if (is_array($value)) {
189-
// If the AD Value is an array, we'll
190-
// retrieve the first value.
191-
$value = Arr::get($value, 0);
192-
}
185+
// If the AD Value is an array, we'll
186+
// retrieve the first value.
187+
$value = (is_array($value) ? Arr::get($value, 0) : $value);
193188
}
194189

195190
return $value;
@@ -236,9 +231,7 @@ protected function getAdldap($provider = null)
236231
{
237232
$ad = Adldap::getFacadeRoot();
238233

239-
if (is_null($provider)) {
240-
$provider = $this->getDefaultConnectionName();
241-
}
234+
$provider = (is_null($provider) ? $this->getDefaultConnectionName() : $provider);
242235

243236
return $ad->getManager()->get($provider);
244237
}

0 commit comments

Comments
 (0)