GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Authorities   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getAuthority() 0 11 4
A authorize() 0 7 3
A validate() 0 7 2
1
<?php
2
/**
3
 * This file is part of the O2System Framework package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @author         Steeve Andrian Salim
9
 * @copyright      Copyright (c) Steeve Andrian Salim
10
 */
11
12
// ------------------------------------------------------------------------
13
14
namespace O2System\Security\Authentication\User;
15
16
// ------------------------------------------------------------------------
17
18
use O2System\Spl\Patterns\Structural\Provider\AbstractProvider;
19
use O2System\Spl\Patterns\Structural\Provider\ValidationInterface;
20
21
/**
22
 * Class Authorities
23
 * @package O2System\Security\Authentication\User
24
 */
25
class Authorities extends AbstractProvider implements ValidationInterface
26
{
27
    /**
28
     * Authorities::validate
29
     *
30
     * Checks if the object is a valid instance.
31
     *
32
     * @param object $object The object to be validated.
33
     *
34
     * @return bool Returns TRUE on valid or FALSE on failure.
35
     */
36
    public function validate($object)
37
    {
38
        if ($object instanceof Authority) {
39
            return true;
40
        }
41
42
        return false;
43
    }
44
45
    public function authorize($segments)
46
    {
47
        if ($authority = $this->getAuthority($segments)) {
48
            return $authority->getPermission() === 'GRANTED' ? true : false;
49
        }
50
51
        return false;
52
    }
53
54
    public function getAuthority($segments)
55
    {
56
        $segments = is_array($segments) ? implode('/', $segments) : $segments;
57
58
        if ($this->exists($segments)) {
59
            if (($authority = $this->getObject($segments)) instanceof Authority) {
60
                return $authority;
61
            }
62
        }
63
64
        return false;
65
    }
66
}