Passed
Push — master ( f2a84f...718fb6 )
by Melech
03:59
created

ClassDispatch::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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\Dispatcher\Data;
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\Dispatcher\Data\Contract\ClassDispatch as Contract;
18
19
/**
20
 * Class ClassDispatch.
21
 *
22
 * @author Melech Mizrachi
23
 */
24
class ClassDispatch extends Dispatch implements Contract
25
{
26
    /**
27
     * @param class-string                 $class        The class name
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string.
Loading history...
28
     * @param array<array-key, mixed>|null $arguments    The arguments
29
     * @param class-string[]|null          $dependencies The dependencies
30
     */
31
    public function __construct(
32
        protected string $class,
33
        protected array|null $arguments = null,
34
        protected array|null $dependencies = null,
35
    ) {
36
    }
37
38
    /**
39
     * @inheritDoc
40
     */
41
    #[Override]
42
    public function getClass(): string
43
    {
44
        return $this->class;
45
    }
46
47
    /**
48
     * @inheritDoc
49
     */
50
    #[Override]
51
    public function withClass(string $class): static
52
    {
53
        $new = clone $this;
54
55
        $new->class = $class;
56
57
        return $new;
58
    }
59
60
    /**
61
     * @inheritDoc
62
     */
63
    #[Override]
64
    public function getArguments(): array|null
65
    {
66
        return $this->arguments;
67
    }
68
69
    /**
70
     * @inheritDoc
71
     */
72
    #[Override]
73
    public function withArguments(array|null $arguments = null): static
74
    {
75
        $new = clone $this;
76
77
        $new->arguments = $arguments;
78
79
        return $new;
80
    }
81
82
    /**
83
     * @inheritDoc
84
     */
85
    #[Override]
86
    public function getDependencies(): array|null
87
    {
88
        return $this->dependencies;
89
    }
90
91
    /**
92
     * @inheritDoc
93
     */
94
    #[Override]
95
    public function withDependencies(array|null $dependencies = null): static
96
    {
97
        $new = clone $this;
98
99
        $new->dependencies = $dependencies;
100
101
        return $new;
102
    }
103
104
    /**
105
     * @inheritDoc
106
     */
107
    #[Override]
108
    public function __toString(): string
109
    {
110
        return $this->class;
111
    }
112
}
113