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.

ReflectionFunction   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 4
dl 0
loc 61
ccs 23
cts 23
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getBody() 0 18 2
A getExtension() 0 9 2
A getParameters() 0 10 2
1
<?php
2
3
namespace Wingu\OctopusCore\Reflection;
4
5
use Wingu\OctopusCore\Reflection\Exceptions\RuntimeException;
6
7
/**
8
 * The ReflectionFunction class reports information about a function.
9
 */
10
class ReflectionFunction extends \ReflectionFunction
11
{
12
13
    use ReflectionDocCommentTrait;
14
15
    /**
16
     * Get the body of the function.
17
     *
18
     * @return string
19
     * @throws \Wingu\OctopusCore\Reflection\Exceptions\RuntimeException If the function is internal.
20
     */
21 15
    public function getBody()
22
    {
23 15
        $fileName = $this->getFileName();
24 15
        if ($fileName === false) {
25 3
            throw new RuntimeException('Can not get body of a function that is internal.');
26
        }
27
28 12
        $lines = file($fileName, FILE_IGNORE_NEW_LINES);
29 12
        $lines = array_slice($lines, $this->getStartLine() - 1, ($this->getEndLine() - $this->getStartLine() + 1),
30 12
            true);
31 12
        $lines = implode("\n", $lines);
32
33 12
        $firstBracketPos = strpos($lines, '{');
34 12
        $lastBracketPost = strrpos($lines, '}');
35 12
        $body = substr($lines, $firstBracketPos + 1, $lastBracketPost - $firstBracketPos - 1);
36
37 12
        return trim(rtrim($body), "\n\r");
38
    }
39
40
    /**
41
     * Gets a ReflectionExtension object for the extension which defined the function.
42
     *
43
     * @return \Wingu\OctopusCore\Reflection\ReflectionExtension
44
     */
45 6
    public function getExtension()
46
    {
47 6
        $extensionName = $this->getExtensionName();
48 6
        if ($extensionName !== false) {
49 3
            return new ReflectionExtension($extensionName);
50
        } else {
51 3
            return null;
52
        }
53
    }
54
55
    /**
56
     * Gets parameters.
57
     *
58
     * @return \Wingu\OctopusCore\Reflection\ReflectionParameter[]
59
     */
60 6
    public function getParameters()
61
    {
62 6
        $res = parent::getParameters();
63
64 6
        foreach ($res as $key => $val) {
65 3
            $res[$key] = new ReflectionParameter($this->getName(), $val->getName());
66 2
        }
67
68 6
        return $res;
69
    }
70
}
71