Passed
Push — 1.x ( 44281e...e2dae5 )
by Kevin
02:12
created

UntypedParameter   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 21
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A type() 0 3 1
A valueFor() 0 7 2
A __construct() 0 3 1
1
<?php
2
3
namespace Zenstruck\Callback\Parameter;
4
5
use Zenstruck\Callback\Exception\UnresolveableArgument;
6
use Zenstruck\Callback\Parameter;
7
8
/**
9
 * @author Kevin Bond <[email protected]>
10
 */
11
final class UntypedParameter extends Parameter
12
{
13
    private $value;
14
15
    public function __construct($value)
16
    {
17
        $this->value = $value;
18
    }
19
20
    public function type(): string
21
    {
22
        return 'mixed';
23
    }
24
25
    protected function valueFor(\ReflectionParameter $parameter)
26
    {
27
        if ($parameter->getType()) {
28
            throw new UnresolveableArgument('Argument has type.');
29
        }
30
31
        return $this->value;
32
    }
33
}
34