ValueHelper   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A compareArguments() 0 16 3
1
<?php
2
3
namespace Digia\GraphQL\Util;
4
5
use Digia\GraphQL\Language\Node\ArgumentNode;
6
use function Digia\GraphQL\printNode;
7
8
class ValueHelper
9
{
10
    /**
11
     * @param ArgumentNode[] $argumentsA
12
     * @param ArgumentNode[] $argumentsB
13
     * @return bool
14
     */
15
    public static function compareArguments(array $argumentsA, array $argumentsB): bool
16
    {
17
        if (\count($argumentsA) !== \count($argumentsB)) {
18
            return false;
19
        }
20
21
        return arrayEvery($argumentsA, function (ArgumentNode $argumentA) use ($argumentsB) {
22
            $argumentB = find($argumentsB, function (ArgumentNode $argument) use ($argumentA) {
23
                return $argument->getNameValue() === $argumentA->getNameValue();
24
            });
25
26
            if (null === $argumentB) {
27
                return false;
28
            }
29
30
            return printNode($argumentA->getValue()) === printNode($argumentB->getValue());
0 ignored issues
show
Bug introduced by
It seems like $argumentA->getValue() can also be of type null; however, parameter $node of Digia\GraphQL\printNode() does only seem to accept Digia\GraphQL\Language\Node\NodeInterface, 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

30
            return printNode(/** @scrutinizer ignore-type */ $argumentA->getValue()) === printNode($argumentB->getValue());
Loading history...
31
        });
32
    }
33
}
34