From a30c041768e16adf0f4d24fb4e04e634f2707376 Mon Sep 17 00:00:00 2001 From: Tim van Dijen <tvdijen@gmail.com> Date: Thu, 4 Jan 2018 14:11:20 +0100 Subject: [PATCH] PSR-2 --- modules/sqlauth/lib/Auth/Source/SQL.php | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/modules/sqlauth/lib/Auth/Source/SQL.php b/modules/sqlauth/lib/Auth/Source/SQL.php index 10f0081ee..e867f9450 100644 --- a/modules/sqlauth/lib/Auth/Source/SQL.php +++ b/modules/sqlauth/lib/Auth/Source/SQL.php @@ -8,27 +8,24 @@ * * @package SimpleSAMLphp */ -class sspmod_sqlauth_Auth_Source_SQL extends sspmod_core_Auth_UserPassBase { - +class sspmod_sqlauth_Auth_Source_SQL extends sspmod_core_Auth_UserPassBase +{ /** * The DSN we should connect to. */ private $dsn; - /** * The username we should connect to the database with. */ private $username; - /** * The password we should connect to the database with. */ private $password; - /** * The query we should use to retrieve the attributes for the user. * @@ -36,14 +33,14 @@ class sspmod_sqlauth_Auth_Source_SQL extends sspmod_core_Auth_UserPassBase { */ private $query; - /** * Constructor for this authentication source. * * @param array $info Information about this authentication source. * @param array $config Configuration. */ - public function __construct($info, $config) { + public function __construct($info, $config) + { assert(is_array($info)); assert(is_array($config)); @@ -77,7 +74,8 @@ class sspmod_sqlauth_Auth_Source_SQL extends sspmod_core_Auth_UserPassBase { * * @return PDO The database connection. */ - private function connect() { + private function connect() + { try { $db = new PDO($this->dsn, $this->username, $this->password); } catch (PDOException $e) { @@ -87,7 +85,6 @@ class sspmod_sqlauth_Auth_Source_SQL extends sspmod_core_Auth_UserPassBase { $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - $driver = explode(':', $this->dsn, 2); $driver = strtolower($driver[0]); @@ -120,7 +117,8 @@ class sspmod_sqlauth_Auth_Source_SQL extends sspmod_core_Auth_UserPassBase { * @param string $password The password the user wrote. * @return array Associative array with the users attributes. */ - protected function login($username, $password) { + protected function login($username, $password) + { assert(is_string($username)); assert(is_string($password)); @@ -134,7 +132,7 @@ class sspmod_sqlauth_Auth_Source_SQL extends sspmod_core_Auth_UserPassBase { } try { - $res = $sth->execute(array('username' => $username, 'password' => $password)); + $sth->execute(array('username' => $username, 'password' => $password)); } catch (PDOException $e) { throw new Exception('sqlauth:' . $this->authId . ': - Failed to execute query: ' . $e->getMessage()); @@ -165,7 +163,7 @@ class sspmod_sqlauth_Auth_Source_SQL extends sspmod_core_Auth_UserPassBase { foreach ($data as $row) { foreach ($row as $name => $value) { - if ($value === NULL) { + if ($value === null) { continue; } @@ -189,5 +187,4 @@ class sspmod_sqlauth_Auth_Source_SQL extends sspmod_core_Auth_UserPassBase { return $attributes; } - } -- GitLab