MissingMethodParamType   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 31
c 0
b 0
f 0
wmc 4
lcom 1
cbo 3
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A param() 0 6 2
A message() 0 11 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Marcosh\PhpTypeChecker\Anomaly;
6
7
use Marcosh\PhpTypeChecker\Check\Parameter;
8
use Roave\BetterReflection\Reflection\ReflectionParameter;
9
10
final class MissingMethodParamType
11
{
12
    /**
13
     * @var ReflectionParameter
14
     */
15
    private $parameter;
16
17
    private function __construct(ReflectionParameter $parameter)
18
    {
19
        $this->parameter = $parameter;
20
    }
21
22
    public static function param(ReflectionParameter $parameter): \Iterator
23
    {
24
        if ((new Parameter($parameter))->typeIsMissing()) {
25
            yield new self($parameter);
26
        }
27
    }
28
29
    public function message(): string
30
    {
31
        return sprintf(
32
            'Parameter <info>%s</info> of method <info>%s</info> of the class <info>%s</info> ' .
33
            'defined in <comment>%s</comment> does not have a type hint.',
34
            $this->parameter->getName(),
35
            $this->parameter->getDeclaringFunction()->getName(),
36
            $this->parameter->getDeclaringFunction()->getDeclaringClass()->getName(),
37
            $this->parameter->getDeclaringFunction()->getFileName()
38
        );
39
    }
40
}
41