Passed
Pull Request — main (#128)
by Tom
02:52
created

ExcludeCriteria::getExcludeCriteria()   A

Complexity

Conditions 5
Paths 4

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 5
eloc 7
c 1
b 0
f 1
nc 4
nop 0
dl 0
loc 13
rs 9.6111
1
<?php
0 ignored issues
show
introduced by
Missing declare(strict_types=1).
Loading history...
2
3
namespace ApiSkeletons\Doctrine\GraphQL\Attribute;
4
5
use ApiSkeletons\Doctrine\GraphQL\Criteria\Filters;
6
7
trait ExcludeCriteria
8
{
9
    /** @return string[] */
10
    public function getExcludeCriteria(): array
11
    {
12
        if ($this->includeCriteria && $this->exccludeCriteria) {
0 ignored issues
show
Bug introduced by
The property exccludeCriteria does not exist on ApiSkeletons\Doctrine\Gr...tribute\ExcludeCriteria. Did you mean excludeCriteria?
Loading history...
13
            throw new \Exception('includeCriteria and excludeCriteria are mutually exclusive.');
0 ignored issues
show
introduced by
Class \Exception should not be referenced via a fully qualified name, but via a use statement.
Loading history...
14
        }
15
16
        if ($this->includeCriteria) {
17
            $this->excludeCriteria = array_diff(Filters::toArray(), $this->includeCriteria);
0 ignored issues
show
Bug Best Practice introduced by
The property excludeCriteria does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
introduced by
Function array_diff() should not be referenced via a fallback global name, but via a use statement.
Loading history...
18
        } else if ($this->excludeCriteria) {
19
            $this->excludeCriteria = array_intersect(Filters::toArray(), $this->excludeCriteria);
0 ignored issues
show
introduced by
Function array_intersect() should not be referenced via a fallback global name, but via a use statement.
Loading history...
20
        }
21
22
        return $this->excludeCriteria;
23
    }
24
}
25
26