UntypedParameter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 24
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\Argument;
6
use Zenstruck\Callback\Exception\UnresolveableArgument;
7
use Zenstruck\Callback\Parameter;
8
use Zenstruck\Callback\ValueFactory;
9
10
/**
11
 * @author Kevin Bond <[email protected]>
12
 */
13
final class UntypedParameter extends Parameter
14
{
15
    private $value;
16
17
    /**
18
     * @param mixed|ValueFactory $value
19
     */
20
    public function __construct($value)
21
    {
22
        $this->value = $value;
23
    }
24
25
    public function type(): string
26
    {
27
        return 'mixed';
28
    }
29
30
    protected function valueFor(Argument $argument)
31
    {
32
        if ($argument->hasType()) {
33
            throw new UnresolveableArgument('Argument has type.');
34
        }
35
36
        return $this->value;
37
    }
38
}
39