Passed
Push — master ( 0e941b...0f3de7 )
by Conrad
08:36
created

ScopeService::hasScope()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 2
1
<?php
2
3
namespace AdvancedLearning\Oauth2Server\Services;
4
5
use SilverStripe\Security\Member;
6
7
class ScopeService
8
{
9
    /**
10
     * Checks whether the member has the specified scope.
11
     *
12
     * @param string $name
13
     * @param Member $member
14
     *
15
     * @return bool
16
     */
17
    public function hasScope(string $name, Member $member): bool
18
    {
19
        return $member->Groups()->filter([
20
            'Scopes.Name' => $name
21
        ])->count() > 0;
22
    }
23
}