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

Commit a633a93

Browse files
committed
Merge pull request #24 from Adldap2/analysis-z4KmNq
Applied fixes from StyleCI
2 parents 701704f + 4ad0b24 commit a633a93

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

src/AdldapAuthUserProvider.php

+19-17
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
namespace Adldap\Laravel;
44

55
use Adldap\Laravel\Facades\Adldap;
6-
use Adldap\Schemas\ActiveDirectory;
76
use Adldap\Models\User;
7+
use Adldap\Schemas\ActiveDirectory;
8+
use Illuminate\Auth\EloquentUserProvider;
9+
use Illuminate\Contracts\Auth\Authenticatable;
10+
use Illuminate\Database\Eloquent\Model;
811
use Illuminate\Support\Arr;
912
use Illuminate\Support\Facades\Config;
10-
use Illuminate\Database\Eloquent\Model;
11-
use Illuminate\Contracts\Auth\Authenticatable;
12-
use Illuminate\Auth\EloquentUserProvider;
1313

1414
class AdldapAuthUserProvider extends EloquentUserProvider
1515
{
1616
/**
17-
* {@inheritDoc}
17+
* {@inheritdoc}
1818
*/
1919
public function retrieveById($identifier)
2020
{
@@ -24,7 +24,7 @@ public function retrieveById($identifier)
2424
}
2525

2626
/**
27-
* {@inheritDoc}
27+
* {@inheritdoc}
2828
*/
2929
public function retrieveByToken($identifier, $token)
3030
{
@@ -34,7 +34,7 @@ public function retrieveByToken($identifier, $token)
3434
}
3535

3636
/**
37-
* {@inheritDoc}
37+
* {@inheritdoc}
3838
*/
3939
public function retrieveByCredentials(array $credentials)
4040
{
@@ -54,11 +54,11 @@ public function retrieveByCredentials(array $credentials)
5454
$user = $query->first();
5555

5656
// If the user is an Adldap User model instance.
57-
if($user instanceof User) {
57+
if ($user instanceof User) {
5858
// Retrieve the users login attribute.
5959
$username = $user->{$this->getLoginAttribute()};
6060

61-
if(is_array($username)) {
61+
if (is_array($username)) {
6262
// We'll make sure we retrieve the users first username
6363
// attribute if it's contained in an array.
6464
$username = Arr::get($username, 0);
@@ -68,18 +68,18 @@ public function retrieveByCredentials(array $credentials)
6868
$key = $this->getPasswordKey();
6969

7070
// Try to log the user in.
71-
if($this->authenticate($username, $credentials[$key])) {
71+
if ($this->authenticate($username, $credentials[$key])) {
7272
// Login was successful, we'll create a new
7373
// Laravel model with the Adldap user.
7474
return $this->getModelFromAdldap($user, $credentials[$key]);
7575
}
7676
}
7777

78-
return null;
78+
return;
7979
}
8080

8181
/**
82-
* Creates a local User from Active Directory
82+
* Creates a local User from Active Directory.
8383
*
8484
* @param User $user
8585
* @param string $password
@@ -107,7 +107,9 @@ protected function getModelFromAdldap(User $user, $password)
107107
$model = $this->createModel()->newQuery()->where([$key => $username])->first();
108108

109109
// Create the model instance of it isn't found.
110-
if(!$model) $model = $this->createModel();
110+
if (!$model) {
111+
$model = $this->createModel();
112+
}
111113

112114
// Set the username and password in case
113115
// of changes in active directory.
@@ -120,7 +122,7 @@ protected function getModelFromAdldap(User $user, $password)
120122
// attributes on the model.
121123
$model = $this->syncModelFromAdldap($user, $model);
122124

123-
if($this->getBindUserToModel()) {
125+
if ($this->getBindUserToModel()) {
124126
$model = $this->bindAdldapToModel($user, $model);
125127
}
126128

@@ -139,10 +141,10 @@ protected function syncModelFromAdldap(User $user, Authenticatable $model)
139141
{
140142
$attributes = $this->getSyncAttributes();
141143

142-
foreach($attributes as $modelField => $adField) {
144+
foreach ($attributes as $modelField => $adField) {
143145
$adValue = $user->{$adField};
144146

145-
if(is_array($adValue)) {
147+
if (is_array($adValue)) {
146148
// If the AD Value is an array, we'll
147149
// retrieve the first value.
148150
$adValue = Arr::get($adValue, 0);
@@ -151,7 +153,7 @@ protected function syncModelFromAdldap(User $user, Authenticatable $model)
151153
$model->{$modelField} = $adValue;
152154
}
153155

154-
if($model instanceof Model) {
156+
if ($model instanceof Model) {
155157
$model->save();
156158
}
157159

src/AdldapServiceProvider.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,17 @@ public function boot()
3535
public function register()
3636
{
3737
// Bind the Adldap instance to the IoC
38-
$this->app->bind('adldap', function()
39-
{
38+
$this->app->bind('adldap', function () {
4039
$config = $this->app['config']->get('adldap');
4140

4241
// Verify configuration.
43-
if(is_null($config)) {
42+
if (is_null($config)) {
4443
$message = 'Adldap configuration could not be found. Try re-publishing using `php artisan vendor:publish --tag="adldap"`.';
4544

4645
throw new ConfigurationMissingException($message);
4746
}
4847

49-
return new Adldap($config['connection_settings'], new $config['connection'], $config['auto_connect']);
48+
return new Adldap($config['connection_settings'], new $config['connection'](), $config['auto_connect']);
5049
});
5150

5251
// Bind the Adldap contract to the Adldap object

0 commit comments

Comments
 (0)