Criteria   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 72
rs 10
c 0
b 0
f 0
wmc 11

11 Methods

Rating   Name   Duplication   Size   Complexity  
A getOffset() 0 3 1
A getArgs() 0 3 1
A __construct() 0 11 1
A getLimit() 0 3 1
A getCollection() 0 3 1
A getContext() 0 3 1
A eventName() 0 4 1
A getInfo() 0 3 1
A getObjectValue() 0 3 1
A setCollection() 0 3 1
A getCriteria() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ApiSkeletons\Doctrine\ORM\GraphQL\Event;
6
7
use Doctrine\Common\Collections\Collection;
8
use Doctrine\Common\Collections\Criteria as DoctrineCriteria;
9
use Doctrine\ORM\PersistentCollection;
10
use GraphQL\Type\Definition\ResolveInfo;
11
use League\Event\HasEventName;
12
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...
13
14
/**
15
 * This event is dispatched when a Doctrine Criteria is created.
16
 * Define an event using the Association::$criteriaEventName
17
 */
18
class Criteria implements
19
    HasEventName
20
{
21
    /**
22
     * @param PersistentCollection<array-key, mixed> $collection
23
     * @param mixed[]                                $args
24
     */
25
    public function __construct(
26
        protected readonly string $eventName,
27
        protected readonly DoctrineCriteria $criteria,
28
        protected Collection $collection,
29
        protected readonly int $offset,
30
        protected readonly int $limit,
31
        protected readonly mixed $objectValue,
32
        protected readonly array $args,
33
        protected readonly mixed $context,
34
        protected readonly ResolveInfo $info,
35
    ) {
36
    }
37
38
    #[Override]
39
    public function eventName(): string
40
    {
41
        return $this->eventName;
42
    }
43
44
    public function getCriteria(): DoctrineCriteria
45
    {
46
        return $this->criteria;
47
    }
48
49
    /** @return PersistentCollection<array-key, mixed> */
50
    public function getCollection(): Collection
51
    {
52
        return $this->collection;
53
    }
54
55
    /** @param Collection<array-key, mixed> $collection */
56
    public function setCollection(Collection $collection): void
57
    {
58
        $this->collection = $collection;
0 ignored issues
show
Documentation Bug introduced by
$collection is of type Doctrine\Common\Collections\Collection, but the property $collection was declared to be of type Doctrine\ORM\PersistentCollection. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
59
    }
60
61
    public function getOffset(): int
62
    {
63
        return $this->offset;
64
    }
65
66
    public function getLimit(): int
67
    {
68
        return $this->limit;
69
    }
70
71
    public function getObjectValue(): mixed
72
    {
73
        return $this->objectValue;
74
    }
75
76
    /** @return mixed[] */
77
    public function getArgs(): array
78
    {
79
        return $this->args;
80
    }
81
82
    public function getContext(): mixed
83
    {
84
        return $this->context;
85
    }
86
87
    public function getInfo(): ResolveInfo
88
    {
89
        return $this->info;
90
    }
91
}
92