Fixed count placement to make code more efficient as per scrutinizer feedback

This commit is contained in:
Andrew Millington 2017-12-29 12:25:39 +00:00
parent 57ca83a8ba
commit 5b79b40df9
No known key found for this signature in database
GPG Key ID: 815DE090877B53F3

View File

@ -49,16 +49,18 @@ $app->get(
],
];
$totalUsers = count($users);
// If the access token doesn't have the `basic` scope hide users' names
if (in_array('basic', $request->getAttribute('oauth_scopes')) === false) {
for ($i = 0; $i < count($users); $i++) {
for ($i = 0; $i < $totalUsers; $i++) {
unset($users[$i]['name']);
}
}
// If the access token doesn't have the `email` scope hide users' email addresses
if (in_array('email', $request->getAttribute('oauth_scopes')) === false) {
for ($i = 0; $i < count($users); $i++) {
for ($i = 0; $i < $totalUsers; $i++) {
unset($users[$i]['email']);
}
}