33namespace CodeIgniter \Shield \Collectors ;
44
55use CodeIgniter \Debug \Toolbar \Collectors \BaseCollector ;
6+ use CodeIgniter \Shield \Auth as ShieldAuth ;
67
78/**
89 * Debug Toolbar Collector for Auth
@@ -41,7 +42,12 @@ class Auth extends BaseCollector
4142 */
4243 protected $ title = 'Auth ' ;
4344
44- //--------------------------------------------------------------------
45+ private ShieldAuth $ auth ;
46+
47+ public function __construct ()
48+ {
49+ $ this ->auth = service ('auth ' );
50+ }
4551
4652 /**
4753 * Returns any information that should be shown next to the title.
@@ -56,11 +62,8 @@ public function getTitleDetails(): string
5662 */
5763 public function display (): string
5864 {
59- /** @var \CodeIgniter\Shield\Auth $auth */
60- $ auth = service ('auth ' );
61-
62- if ($ auth ->loggedIn ()) {
63- $ user = $ auth ->user ();
65+ if ($ this ->auth ->loggedIn ()) {
66+ $ user = $ this ->auth ->user ();
6467 $ groups = $ user ->getGroups ();
6568
6669 $ groupsForUser = implode (', ' , $ groups );
@@ -86,10 +89,7 @@ public function display(): string
8689 */
8790 public function getBadgeValue ()
8891 {
89- /** @var \CodeIgniter\Shield\Auth $auth */
90- $ auth = service ('auth ' );
91-
92- return $ auth ->loggedIn () ? $ auth ->id () : null ;
92+ return $ this ->auth ->loggedIn () ? $ this ->auth ->id () : null ;
9393 }
9494
9595 /**
0 commit comments