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

PropertyDispatch::__toString()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
dl 0
loc 6
rs 10
c 1
b 0
f 0
cc 2
nc 2
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\PropertyDispatch as Contract;
18
19
/**
20
 * Class PropertyDispatch.
21
 *
22
 * @author Melech Mizrachi
23
 */
24
class PropertyDispatch extends ClassDispatch 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 non-empty-string             $property     The property name
29
     * @param array<array-key, mixed>|null $arguments    The arguments
30
     * @param class-string[]|null          $dependencies The dependencies
31
     */
32
    public function __construct(
33
        string $class,
34
        protected string $property,
35
        protected bool $isStatic = false,
36
        array|null $arguments = null,
37
        array|null $dependencies = null
38
    ) {
39
        parent::__construct(
40
            class: $class,
41
            arguments: $arguments,
42
            dependencies: $dependencies
43
        );
44
    }
45
46
    /**
47
     * @inheritDoc
48
     */
49
    #[Override]
50
    public function getProperty(): string
51
    {
52
        return $this->property;
53
    }
54
55
    /**
56
     * @inheritDoc
57
     */
58
    #[Override]
59
    public function withProperty(string $property): static
60
    {
61
        $new = clone $this;
62
63
        $new->property = $property;
64
65
        return $new;
66
    }
67
68
    /**
69
     * @inheritDoc
70
     */
71
    #[Override]
72
    public function isStatic(): bool
73
    {
74
        return $this->isStatic;
75
    }
76
77
    /**
78
     * @inheritDoc
79
     */
80
    #[Override]
81
    public function withIsStatic(bool $isStatic): static
82
    {
83
        $new = clone $this;
84
85
        $new->isStatic = $isStatic;
86
87
        return $new;
88
    }
89
90
    /**
91
     * @inheritDoc
92
     */
93
    #[Override]
94
    public function __toString(): string
95
    {
96
        return $this->class
97
            . ($this->isStatic ? '::' : '->')
98
            . $this->property;
99
    }
100
}
101