Argument   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A withType() 0 6 1
A getRootValues() 0 3 1
A getName() 0 3 1
A getType() 0 3 1
A __construct() 0 5 1
A getValueByArgumentName() 0 3 2
1
<?php
2
/**
3
 * Schema Validator
4
 *
5
 * @author Vlad Shashkov <[email protected]>
6
 * @copyright Copyright (c) 2021, The Myaza Software
7
 */
8
9
declare(strict_types=1);
10
11
namespace SchemaValidator;
12
13
/**
14
 * @codeCoverageIgnore
15
 */
16
final class Argument
17
{
18
    public function __construct(
19
        private string $name,
20
        private array $rootValues,
21
        private \ReflectionType $type,
22
    ) {
23
    }
24
25
    public function getRootValues(): array
26
    {
27
        return $this->rootValues;
28
    }
29
30
    public function getName(): string
31
    {
32
        return $this->name;
33
    }
34
35
    public function getType(): \ReflectionType
36
    {
37
        return $this->type;
38
    }
39
40
    public function getValueByArgumentName(): mixed
41
    {
42
        return array_key_exists($this->name, $this->rootValues) ? $this->rootValues[$this->name] : null;
43
    }
44
45
    public function withType(\ReflectionType $type): self
46
    {
47
        $new       = clone $this;
48
        $new->type = $type;
49
50
        return $new;
51
    }
52
}
53