Test Failed
Push — master ( a0df59...1a96aa )
by butschster
08:17
created

AbstractTarget   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 3
c 1
b 0
f 0
dl 0
loc 33
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A __toString() 0 3 1
A getScope() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiral\Tokenizer\Attribute;
6
7
abstract class AbstractTarget implements \Stringable
8
{
9
    /**
10
     * @param non-empty-string|null $scope
0 ignored issues
show
Documentation Bug introduced by
The doc comment non-empty-string|null at position 0 could not be parsed: Unknown type name 'non-empty-string' at position 0 in non-empty-string|null.
Loading history...
11
     */
12
    public function __construct(
13
        public readonly ?string $scope = null,
14
    ) {
15
    }
16
17
    /**
18
     * Generates a unique string for this target to be used as cache key.
19
     * @return non-empty-string
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...
20
     */
21
    public function __toString(): string
22
    {
23
        return \md5(\print_r($this, return: true));
0 ignored issues
show
Bug introduced by
It seems like print_r($this, true) can also be of type true; however, parameter $string of md5() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

23
        return \md5(/** @scrutinizer ignore-type */ \print_r($this, return: true));
Loading history...
24
    }
25
26
    /**
27
     * Filter given classes and return only those that should be listened.
28
     * @param \ReflectionClass[] $classes
29
     * @return \Iterator<class-string>
30
     */
31
    abstract public function filter(array $classes): \Iterator;
32
33
    /**
34
     * Get scope for class locator. If scope is not set, all classes will be listened.
35
     * @return non-empty-string|null
0 ignored issues
show
Documentation Bug introduced by
The doc comment non-empty-string|null at position 0 could not be parsed: Unknown type name 'non-empty-string' at position 0 in non-empty-string|null.
Loading history...
36
     */
37
    public function getScope(): ?string
38
    {
39
        return $this->scope;
40
    }
41
}
42