Passed
Push — master ( af5ff0...adbbe6 )
by Pieter
02:24
created

SubAction::getSummary()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 7
nc 2
nop 0
dl 0
loc 10
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace W2w\Lib\Apie\OpenApiSchema\SubActions;
4
5
use phpDocumentor\Reflection\DocBlockFactory;
6
use ReflectionMethod;
7
use Symfony\Component\PropertyInfo\Type;
8
9
class SubAction
10
{
11
    /**
12
     * @var string
13
     */
14
    private $name;
15
16
    /**
17
     * @var (Type|null)[]
18
     */
19
    private $arguments;
20
21
    /**
22
     * @var Type|null
23
     */
24
    private $returnTypehint;
25
26
    /**
27
     * @var ReflectionMethod
28
     */
29
    private $reflectionMethod;
30
31
    /**
32
     * @var object|null
33
     */
34
    private $object;
35
36
    /**
37
     * @param string $name
38
     * @param (Type|null)[] $arguments
39
     * @param ReflectionMethod $reflectionMethod
40
     * @param Type|null $returnTypehint
41
     * @param object|null $object
42
     */
43
    public function __construct(string $name, array $arguments, ReflectionMethod $reflectionMethod, ?Type $returnTypehint, ?object $object) {
44
        $this->name = $name;
45
        $this->arguments = $arguments;
46
        $this->reflectionMethod = $reflectionMethod;
47
        $this->returnTypehint = $returnTypehint;
48
        $this->object = $object;
49
    }
50
51
    /**
52
     * @return string
53
     */
54
    public function getName(): string
55
    {
56
        return $this->name;
57
    }
58
59
    public function getSummary(): ?string
60
    {
61
        $factory  = DocBlockFactory::createInstance();
62
        $docComment = $this->reflectionMethod->getDocComment();
63
        var_dump($docComment);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($docComment) looks like debug code. Are you sure you do not want to remove it?
Loading history...
64
        if (!$docComment) {
65
            return null;
66
        }
67
        $docblock = $factory->create($docComment);
0 ignored issues
show
Bug introduced by
It seems like $docComment can also be of type true; however, parameter $docblock of phpDocumentor\Reflection\DocBlockFactory::create() does only seem to accept object|string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

67
        $docblock = $factory->create(/** @scrutinizer ignore-type */ $docComment);
Loading history...
68
        return $docblock->getDescription() ? : null;
69
    }
70
71
    /**
72
     * @return Type[]
73
     */
74
    public function getArguments(): array
75
    {
76
        return $this->arguments;
77
    }
78
79
    /**
80
     * @return Type|null
81
     */
82
    public function getReturnTypehint(): ?Type
83
    {
84
        return $this->returnTypehint;
85
    }
86
87
    /**
88
     * @return ReflectionMethod
89
     */
90
    public function getReflectionMethod(): ReflectionMethod
91
    {
92
        return $this->reflectionMethod;
93
    }
94
95
    /**
96
     * @return object|null
97
     */
98
    public function getObject(): ?object
99
    {
100
        return $this->object;
101
    }
102
}
103