Passed
Push — master ( 3e0ae5...66dbef )
by Melech
01:47 queued 20s
created

Parameter   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 84
rs 10
c 0
b 0
f 0
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
A getDescription() 0 4 1
A withDescription() 0 8 1
A __construct() 0 5 1
A withName() 0 8 1
A withCast() 0 8 1
A getCast() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Valkyrja Framework package.
7
 *
8
 * (c) Melech Mizrachi <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Valkyrja\Cli\Routing\Data\Abstract;
15
16
use Override;
0 ignored issues
show
Bug introduced by
The type Override was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
use Valkyrja\Cli\Routing\Data\Contract\Parameter as Contract;
18
use Valkyrja\Type\Data\Cast;
19
20
/**
21
 * Abstract Class Parameter.
22
 *
23
 * @author Melech Mizrachi
24
 */
25
abstract class Parameter implements Contract
26
{
27
    /**
28
     * @param non-empty-string $name        The name
0 ignored issues
show
Documentation Bug introduced by
The doc comment non-empty-string at position 0 could not be parsed: Unknown type name 'non-empty-string' at position 0 in non-empty-string.
Loading history...
29
     * @param non-empty-string $description The description
30
     */
31
    public function __construct(
32
        protected string $name,
33
        protected string $description,
34
        protected Cast|null $cast = null,
35
    ) {
36
    }
37
38
    /**
39
     * @inheritDoc
40
     */
41
    #[Override]
42
    public function getName(): string
43
    {
44
        return $this->name;
45
    }
46
47
    /**
48
     * @inheritDoc
49
     */
50
    #[Override]
51
    public function withName(string $name): static
52
    {
53
        $new = clone $this;
54
55
        $new->name = $name;
56
57
        return $new;
58
    }
59
60
    /**
61
     * @inheritDoc
62
     */
63
    #[Override]
64
    public function getCast(): Cast|null
65
    {
66
        return $this->cast;
67
    }
68
69
    /**
70
     * @inheritDoc
71
     */
72
    #[Override]
73
    public function withCast(Cast|null $cast = null): static
74
    {
75
        $new = clone $this;
76
77
        $new->cast = $cast;
78
79
        return $new;
80
    }
81
82
    /**
83
     * @inheritDoc
84
     */
85
    #[Override]
86
    public function getDescription(): string
87
    {
88
        return $this->description;
89
    }
90
91
    /**
92
     * @inheritDoc
93
     */
94
    #[Override]
95
    public function withDescription(string $description): static
96
    {
97
        $new = clone $this;
98
99
        $new->description = $description;
100
101
        return $new;
102
    }
103
104
    /**
105
     * @inheritDoc
106
     */
107
    #[Override]
108
    abstract public function getCastValues(): array;
109
}
110