UntypedParameter::valueFor()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 7
rs 10
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