From 5b79b40df9c9a057602c17f6dace2bc88d201b85 Mon Sep 17 00:00:00 2001 From: Andrew Millington Date: Fri, 29 Dec 2017 12:25:39 +0000 Subject: [PATCH] Fixed count placement to make code more efficient as per scrutinizer feedback --- examples/public/api.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/public/api.php b/examples/public/api.php index 3032ffed..2f896434 100644 --- a/examples/public/api.php +++ b/examples/public/api.php @@ -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']); } }