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

GlobalVariableDispatch::__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\GlobalVariableDispatch as Contract;
18
19
/**
20
 * Class GlobalVariableDispatch.
21
 *
22
 * @author Melech Mizrachi
23
 */
24
class GlobalVariableDispatch extends Dispatch implements Contract
25
{
26
    /**
27
     * @param non-empty-string $variable The variable 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...
28
     */
29
    public function __construct(
30
        protected string $variable
31
    ) {
32
    }
33
34
    /**
35
     * @inheritDoc
36
     */
37
    #[Override]
38
    public function getVariable(): string
39
    {
40
        return $this->variable;
41
    }
42
43
    /**
44
     * @inheritDoc
45
     */
46
    #[Override]
47
    public function withVariable(string $variable): static
48
    {
49
        $new = clone $this;
50
51
        $new->variable = $variable;
52
53
        return $new;
54
    }
55
56
    /**
57
     * @inheritDoc
58
     */
59
    #[Override]
60
    public function __toString(): string
61
    {
62
        return $this->variable;
63
    }
64
}
65