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.
Completed
Push — master ( d721d3...c6e538 )
by Rias
13s queued 12s
created

Backtrace   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 60
rs 10
c 0
b 0
f 0
wmc 11
lcom 1
cbo 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getArguments() 0 4 1
A getFunctionName() 0 4 1
A getObject() 0 8 3
A getHash() 0 13 3
A staticCall() 0 4 1
A globalFunction() 0 4 1
1
<?php
2
3
namespace Spatie\Once;
4
5
class Backtrace
6
{
7
    /** @var array */
8
    protected $trace;
9
10
    /** @var array */
11
    protected $zeroStack;
12
13
    public function __construct(array $trace)
14
    {
15
        $this->trace = $trace[1];
16
        $this->zeroStack = $trace[0];
17
    }
18
19
    public function getArguments(): array
20
    {
21
        return $this->trace['args'];
22
    }
23
24
    public function getFunctionName(): string
25
    {
26
        return $this->trace['function'];
27
    }
28
29
    /**
30
     * @return mixed
31
     */
32
    public function getObject()
33
    {
34
        if ($this->globalFunction()) {
35
            return $this->zeroStack['file'];
36
        }
37
38
        return $this->staticCall() ? $this->trace['class'] : $this->trace['object'];
39
    }
40
41
    public function getHash(): string
42
    {
43
        $normalizedArguments = array_map(function ($argument) {
44
            return is_object($argument) ? spl_object_hash($argument) : $argument;
45
        }, $this->getArguments());
46
47
        $prefix = $this->getFunctionName();
48
        if (strpos($prefix, '{closure}') !== false) {
49
            $prefix = $this->zeroStack['line'];
50
        }
51
52
        return md5($prefix.serialize($normalizedArguments));
53
    }
54
55
    protected function staticCall()
56
    {
57
        return $this->trace['type'] == '::';
58
    }
59
60
    protected function globalFunction()
61
    {
62
        return ! isset($this->trace['type']);
63
    }
64
}
65