Test Failed
Pull Request — master (#2)
by Ashoka
03:06
created

FunctionTrait::getFunctionName()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 6
rs 9.4285
1
<?php
2
/**
3
 * Copyright MediaCT. All rights reserved.
4
 * https://www.mediact.nl
5
 */
6
namespace Mediact\CodingStandard;
7
8
use PHP_CodeSniffer\Files\File;
0 ignored issues
show
Bug introduced by
The type PHP_CodeSniffer\Files\File was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
10
trait FunctionTrait
11
{
12
    /**
13
     * Get a function name.
14
     *
15
     * @param File $file
16
     * @param int  $functionIndex
17
     *
18
     * @return bool|string
19
     */
20
    protected function getFunctionName(File $file, $functionIndex)
21
    {
22
        $index = $this->findFunctionNameIndex($file, $functionIndex);
23
        return $index
24
            ? $file->getTokens()[$index]['content']
25
            : false;
26
    }
27
28
    /**
29
     * Find the function name index.
30
     *
31
     * @param File $file
32
     * @param int  $functionIndex
33
     *
34
     * @return bool|int
35
     */
36
    protected function findFunctionNameIndex(File $file, $functionIndex)
37
    {
38
        return $file->findNext([T_STRING], $functionIndex);
39
    }
40
41
    /**
42
     * Find the start of a function body.
43
     *
44
     * @param File $file
45
     * @param int  $functionIndex
46
     *
47
     * @return bool|int
48
     */
49
    protected function findFunctionBodyStartIndex(File $file, $functionIndex)
50
    {
51
        return $file->findNext([T_SEMICOLON, T_OPEN_CURLY_BRACKET], $functionIndex);
0 ignored issues
show
Bug introduced by
The constant Mediact\CodingStandard\T_OPEN_CURLY_BRACKET was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The constant Mediact\CodingStandard\T_SEMICOLON was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
52
    }
53
}
54