Argument::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

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