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 ( cb09cd...fe481e )
by Cees-Jan
02:38
created

EmptyLineAboveDocblocksFixer::fix()   B

Complexity

Conditions 5
Paths 3

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 5

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 18
ccs 11
cts 11
cp 1
rs 8.8571
cc 5
eloc 11
nc 3
nop 2
crap 5
1
<?php
2
3
namespace WyriHaximus\ApiClient\Tools;
4
5
use Symfony\CS\AbstractFixer;
6
use Symfony\CS\Tokenizer\Tokens;
7
8
class EmptyLineAboveDocblocksFixer extends AbstractFixer
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13 1
    public function fix(\SplFileInfo $file, $content)
14
    {
15 1
        $tokens = Tokens::fromCode($content);
16
17 1
        for ($index = 2; $index < count($tokens); $index++) {
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function count() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
18 1
            $token = $tokens[$index];
19 1
            $previousToken = $tokens[$index - 1];
20 1
            $sndPreviousToken = $tokens[$index - 2];
21 1
            if ($sndPreviousToken->getContent() !== '{' &&
22 1
                substr($token->getContent(), 0, 3) === '/**' &&
23 1
                $previousToken->getLine() === $token->getLine() - 1
24
            ) {
25 1
                $previousToken->setContent(PHP_EOL . $previousToken->getContent());
26
            }
27
        }
28
29 1
        return $tokens->generateCode();
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function getDescription()
36
    {
37
        return 'Ensure there is an empty line behind abstract or interface methods.';
38
    }
39
}
40