Skip to content

Commit c6e649f

Browse files
committed
PSR-2 fixups
1 parent 2031cd0 commit c6e649f

2 files changed

Lines changed: 30 additions & 11 deletions

File tree

lib/Auth/Process/AttributeFromSQL.php

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
*
88
* This filter allows you to add attributes from a SQL datasource
99
*
10-
* @author Guy Halse http://orcid.org/0000-0002-9388-8592
10+
* @author Guy Halse, http://orcid.org/0000-0002-9388-8592
1111
* @copyright Copyright (c) 2019, SAFIRE - South African Identity Federation
12-
* @license https://github.com/safire-ac-za/simplesamlphp-module-sqlattribs/blob/master/LICENSE MIT License
13-
* @package SimpleSAMLphp
12+
* @license https://github.com/safire-ac-za/simplesamlphp-module-sqlattribs/blob/master/LICENSE MIT License
13+
* @package SimpleSAMLphp
1414
*/
1515
class AttributeFromSQL extends \SimpleSAML\Auth\ProcessingFilter
1616
{
@@ -106,7 +106,8 @@ private function connect()
106106
$db = new \PDO($this->dsn, $this->username, $this->password);
107107
} catch (\PDOException $e) {
108108
throw new \SimpleSAML\Error\Exception('AttributeFromSQL: Failed to connect to \'' .
109-
$this->dsn . '\': ' . $e->getMessage());
109+
$this->dsn . '\': ' . $e->getMessage()
110+
);
110111
}
111112
$db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
112113

@@ -132,6 +133,7 @@ private function connect()
132133
* Logic is largely the same as (and lifted from) sqlauth:sql
133134
* @param mixed &$request
134135
* @throws \SimpleSAML\Error\Exception
136+
* @return void
135137
*/
136138
public function process(&$request)
137139
{
@@ -149,16 +151,24 @@ public function process(&$request)
149151
$db = $this->connect();
150152

151153
try {
152-
$sth = $db->prepare('SELECT `attribute`,`value` FROM ' . $this->table . ' WHERE `uid`=? AND (`sp`=\'%\' OR `sp`=?)' . ($this->ignoreExpiry ? '' : ' AND `expires`>CURRENT_DATE') . ';');
154+
$sth = $db->prepare(
155+
'SELECT `attribute`,`value` FROM ' .
156+
$this->table .
157+
' WHERE `uid`=? AND (`sp`=\'%\' OR `sp`=?)' .
158+
($this->ignoreExpiry ? '' : ' AND `expires`>CURRENT_DATE') .
159+
';'
160+
);
153161
} catch (\PDOException $e) {
154162
throw new \SimpleSAML\Error\Exception('AttributeFromSQL: prepare() failed: ' . $e->getMessage());
155163
}
156164

157165
try {
158166
$res = $sth->execute([$attributes[$this->attribute][0], $request["Destination"]["entityid"]]);
159167
} catch (\PDOException $e) {
160-
throw new \SimpleSAML\Error\Exception('AttributeFromSQL: execute(' . $attributes[$this->attribute][0] .
161-
', ' . $request["Destination"]["entityid"] . ') failed: ' . $e->getMessage());
168+
throw new \SimpleSAML\Error\Exception(
169+
'AttributeFromSQL: execute(' . $attributes[$this->attribute][0] .
170+
', ' . $request["Destination"]["entityid"] . ') failed: ' . $e->getMessage()
171+
);
162172
}
163173

164174
try {
@@ -169,7 +179,10 @@ public function process(&$request)
169179
}
170180

171181
if (count($data) === 0) {
172-
\SimpleSAML\Logger::info('AttributeFromSQL: no additional attributes for ' . $this->attribute . '=\'' . $attributes[$this->attribute][0] . '\'');
182+
\SimpleSAML\Logger::info(
183+
'AttributeFromSQL: no additional attributes for ' .
184+
$this->attribute . '=\'' . $attributes[$this->attribute][0] . '\''
185+
);
173186
return;
174187
}
175188

@@ -188,7 +201,10 @@ public function process(&$request)
188201

189202
/* Limit the attribute set returned */
190203
if ($this->limit !== null && !in_array($name, $this->limit, true)) {
191-
\SimpleSAML\Logger::notice('AttributeFromSQL: skipping unwanted attribute ' . $name . ' [limited to: ' . var_export($this->limit, true) . ']');
204+
\SimpleSAML\Logger::notice(
205+
'AttributeFromSQL: skipping unwanted attribute ' .
206+
$name . ' [limited to: ' . var_export($this->limit, true) . ']'
207+
);
192208
continue;
193209
}
194210

@@ -198,7 +214,10 @@ public function process(&$request)
198214

199215
if (in_array($value, $attributes[$name], true)) {
200216
/* Value already exists in attribute. */
201-
\SimpleSAML\Logger::debug('AttributeFromSQL: skipping duplicate attribute/value tuple ' . $name . '=\'' . $value . '\'');
217+
\SimpleSAML\Logger::debug(
218+
'AttributeFromSQL: skipping duplicate attribute/value tuple ' .
219+
$name . '=\'' . $value . '\''
220+
);
202221
continue;
203222
}
204223

tests/lib/Auth/Process/AttributeFromSQLTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ public function testReplace()
105105
];
106106
$this->assertEquals($expectedData, $attributes, "Expected data was not correct");
107107
}
108+
108109
/**
109110
* Test attribute replacement
110111
*/
111-
112112
public function testIgnoreExpires()
113113
{
114114
$config = [

0 commit comments

Comments
 (0)