foothing/laravel-wrappr

View on GitHub
src/Foothing/Wrappr/Providers/Users/DefaultProvider.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php namespace Foothing\Wrappr\Providers\Users;

use Illuminate\Contracts\Auth\Guard;

class DefaultProvider implements UserProviderInterface {
    protected $guard;

    function __construct(Guard $guard) {
        $this->guard = $guard;
    }

    function getAuthUser() {
        return $this->guard->user();
    }

    function isSuperAdmin($user) {
        // Expect user to implement the isSuperAdmin() method.
        if (method_exists($user, 'isSuperAdmin')) {
            return $user->isSuperAdmin();
        }

        throw new \Exception("User implementation doesn't provide isSuperAdmin");
    }
}