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 ( 3e29f4...a0257c )
by Gytis
03:40 queued 11s
created

ConstTypeSubject   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
dl 0
loc 40
ccs 20
cts 20
cp 1
rs 10
c 1
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 16 1
A fromElement() 0 14 3
1
<?php
2
3
namespace Gskema\TypeSniff\Inspection\Subject;
4
5
use Gskema\TypeSniff\Core\CodeElement\Element\AbstractFqcnConstElement;
6
use Gskema\TypeSniff\Core\DocBlock\DocBlock;
7
use Gskema\TypeSniff\Core\DocBlock\Tag\VarTag;
8
use Gskema\TypeSniff\Core\Type\Common\UndefinedType;
9
use Gskema\TypeSniff\Core\Type\TypeInterface;
10
11
class ConstTypeSubject extends AbstractTypeSubject
12
{
13 2
    public function __construct(
14
        ?TypeInterface $docType,
15
        ?TypeInterface $valueType,
16
        ?int $docTypeLine,
17
        int $fnTypeLine,
18
        string $name,
19
        DocBlock $docBlock
20
    ) {
21 2
        parent::__construct(
22 2
            $docType,
23 2
            new UndefinedType(), // not in PHP 7.4 :(
24 2
            $valueType,
25 2
            $docTypeLine,
26 2
            $fnTypeLine,
27 2
            $name,
28 2
            $docBlock
29
        );
30 2
    }
31
32
    /**
33
     * @param AbstractFqcnConstElement $const
34
     *
35
     * @return static
36
     */
37 2
    public static function fromElement(AbstractFqcnConstElement $const)
38
    {
39 2
        $docBlock = $const->getDocBlock();
40
41
        /** @var VarTag|null $varTag */
42 2
        $varTag = $docBlock->getTagsByName('var')[0] ?? null;
43
44 2
        return new static(
45 2
            $varTag ? $varTag->getType() : null,
46 2
            $const->getValueType(),
47 2
            $varTag ? $varTag->getLine() : null,
48 2
            $const->getLine(),
49 2
            $const->getConstName().' constant',
50 2
            $docBlock
51
        );
52
    }
53
}
54