Identity   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 11
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A hasRole() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * BEdita, API-first content management framework
6
 * Copyright 2022 Atlas Srl, Chialab Srl
7
 *
8
 * This file is part of BEdita: you can redistribute it and/or modify
9
 * it under the terms of the GNU Lesser General Public License as published
10
 * by the Free Software Foundation, either version 3 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * See LICENSE.LGPL or <http://gnu.org/licenses/lgpl-3.0.html> for more details.
14
 */
15
namespace BEdita\WebTools;
16
17
use Authentication\Identity as AuthenticationIdentity;
18
19
/**
20
 * Extends Authorization Identity adding useful methods.
21
 */
22
class Identity extends AuthenticationIdentity
23
{
24
    /**
25
     * Return true if `$name` is a role of the identity
26
     *
27
     * @param string $name The role name
28
     * @return bool
29
     */
30
    public function hasRole(string $name): bool
31
    {
32
        return in_array($name, (array)$this->get('roles'));
33
    }
34
}
35