From a1035b1acb72b23be6be973f4a6e61b21246f3e8 Mon Sep 17 00:00:00 2001 From: Sascha Dens Date: Sun, 23 Aug 2015 14:49:52 -0400 Subject: [PATCH] Applied fixes from StyleCI --- .../LdapConnector/LdapUserProviderSpec.php | 9 +++---- src/Dsdevbe/LdapConnector/Adapter/Adldap.php | 7 +++++- .../LdapConnector/Adapter/LdapInterface.php | 3 +++ src/Dsdevbe/LdapConnector/Config/ldap.php | 22 ++++++++-------- .../LdapConnectorServiceProvider.php | 15 +++++------ .../LdapConnector/LdapUserProvider.php | 25 ++++++++++++------- src/Dsdevbe/LdapConnector/Model/User.php | 5 ++-- 7 files changed, 51 insertions(+), 35 deletions(-) diff --git a/spec/Dsdevbe/LdapConnector/LdapUserProviderSpec.php b/spec/Dsdevbe/LdapConnector/LdapUserProviderSpec.php index 6442551..a66bbf7 100644 --- a/spec/Dsdevbe/LdapConnector/LdapUserProviderSpec.php +++ b/spec/Dsdevbe/LdapConnector/LdapUserProviderSpec.php @@ -4,21 +4,20 @@ use Dsdevbe\LdapConnector\Adapter\LdapInterface; use PhpSpec\ObjectBehavior; -use Prophecy\Argument; class LdapUserProviderSpec extends ObjectBehavior { - function let(LdapInterface $interface) + public function let(LdapInterface $interface) { $this->beConstructedWith($interface); } - function it_is_initializable() + public function it_is_initializable() { $this->shouldHaveType('Dsdevbe\LdapConnector\LdapUserProvider'); } - function it_validate_user_by_credentials(LdapInterface $interface) + public function it_validate_user_by_credentials(LdapInterface $interface) { $user = [ 'username' => 'john.doe@example.com', @@ -29,7 +28,7 @@ function it_validate_user_by_credentials(LdapInterface $interface) $this->retrieveByCredentials($user); } - function it_retrieves_user_by_id(LdapInterface $interface) + public function it_retrieves_user_by_id(LdapInterface $interface) { $identifier = 'john.doe@example.com'; diff --git a/src/Dsdevbe/LdapConnector/Adapter/Adldap.php b/src/Dsdevbe/LdapConnector/Adapter/Adldap.php index bc7cc1a..36572f6 100644 --- a/src/Dsdevbe/LdapConnector/Adapter/Adldap.php +++ b/src/Dsdevbe/LdapConnector/Adapter/Adldap.php @@ -1,4 +1,5 @@ $this->_password, ]); $model->setGroups($groups); + return $model; } @@ -30,6 +32,7 @@ public function __construct($config) /** * @param String $username * @param String $password + * * @return bool */ public function connect($username, $password) @@ -50,6 +53,7 @@ public function isConnected() /** * @param String $username + * * @return UserModel */ public function getUserInfo($username) @@ -57,10 +61,11 @@ public function getUserInfo($username) $user = $this->_ldap->user()->info($username); if (!$user) { - return null; + return; } $groups = $this->_ldap->user()->groups($username); + return $this->mapDataToUserModel($username, $groups); } } diff --git a/src/Dsdevbe/LdapConnector/Adapter/LdapInterface.php b/src/Dsdevbe/LdapConnector/Adapter/LdapInterface.php index c15cd25..93ee360 100644 --- a/src/Dsdevbe/LdapConnector/Adapter/LdapInterface.php +++ b/src/Dsdevbe/LdapConnector/Adapter/LdapInterface.php @@ -1,4 +1,5 @@ array( - 'adldap' => array( - 'account_suffix'=> '@domain.local', - 'domain_controllers'=> array( +return [ + 'plugins' => [ + 'adldap' => [ + 'account_suffix' => '@domain.local', + 'domain_controllers' => [ '192.168.0.1', - 'dc02.domain.local' - ), // Load balancing domain controllers - 'base_dn' => 'DC=domain,DC=local', + 'dc02.domain.local', + ], // Load balancing domain controllers + 'base_dn' => 'DC=domain,DC=local', 'admin_username' => 'admin', // This is required for session persistance in the application 'admin_password' => 'yourPassword', - ), - ), -); + ], + ], +]; diff --git a/src/Dsdevbe/LdapConnector/LdapConnectorServiceProvider.php b/src/Dsdevbe/LdapConnector/LdapConnectorServiceProvider.php index 908cd0d..ba15791 100644 --- a/src/Dsdevbe/LdapConnector/LdapConnectorServiceProvider.php +++ b/src/Dsdevbe/LdapConnector/LdapConnectorServiceProvider.php @@ -1,4 +1,5 @@ publishConfig($ldapConfig); } @@ -51,18 +51,18 @@ public function register() */ public function provides() { - return array('auth'); + return ['auth']; } protected function publishConfig($configPath) { - $this->publishes(array( - $configPath => config_path('ldap.php') - )); + $this->publishes([ + $configPath => config_path('ldap.php'), + ]); } /** - * Get ldap configuration + * Get ldap configuration. * * @return array */ @@ -73,6 +73,7 @@ public function getLdapConfig() /** * @param $pluginName + * * @return array */ public function getLdapAdapterConfig($pluginName) diff --git a/src/Dsdevbe/LdapConnector/LdapUserProvider.php b/src/Dsdevbe/LdapConnector/LdapUserProvider.php index 1689a7a..eca2db8 100644 --- a/src/Dsdevbe/LdapConnector/LdapUserProvider.php +++ b/src/Dsdevbe/LdapConnector/LdapUserProvider.php @@ -1,4 +1,6 @@ -_groups); } - }