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.

ConstTypeSubject   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 22
dl 0
loc 56
ccs 16
cts 16
cp 1
rs 10
c 1
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 20 1
A fromElement() 0 16 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
    /**
14
     * @param TypeInterface|null $docType
15
     * @param TypeInterface|null $valueType
16
     * @param int|null           $docTypeLine
17
     * @param int                $fnTypeLine
18
     * @param string             $name
19
     * @param DocBlock           $docBlock
20
     * @param string[]           $attributeNames
21
     * @param string             $id
22
     */
23 7
    public function __construct(
24
        ?TypeInterface $docType,
25
        ?TypeInterface $valueType,
26
        ?int $docTypeLine,
27
        int $fnTypeLine,
28
        string $name,
29
        DocBlock $docBlock,
30
        array $attributeNames,
31
        string $id
32
    ) {
33 7
        parent::__construct(
34 7
            $docType,
35 7
            new UndefinedType(), // not in PHP 7.4 :(
36
            $valueType,
37
            $docTypeLine,
38
            $fnTypeLine,
39
            $name,
40
            $docBlock,
41
            $attributeNames,
42
            $id
43
        );
44 7
    }
45
46
    /**
47
     * @param AbstractFqcnConstElement $const
48
     *
49
     * @return static
50
     */
51 7
    public static function fromElement(AbstractFqcnConstElement $const)
52
    {
53 7
        $docBlock = $const->getDocBlock();
54
55
        /** @var VarTag|null $varTag */
56 7
        $varTag = $docBlock->getTagsByName('var')[0] ?? null;
57
58 7
        return new static(
59 7
            $varTag ? $varTag->getType() : null,
60 7
            $const->getValueType(),
61 7
            $varTag ? $varTag->getLine() : null,
62 7
            $const->getLine(),
63 7
            $const->getConstName() . ' constant',
64
            $docBlock,
65 7
            $const->getAttributeNames(),
66 7
            $const->getFqcn() . '::' . $const->getConstName()
67
        );
68
    }
69
}
70