RecordSearch::build()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1.1623

Importance

Changes 0
Metric Value
eloc 10
c 0
b 0
f 0
dl 0
loc 17
ccs 5
cts 11
cp 0.4545
rs 9.9332
cc 1
nc 1
nop 0
crap 1.1623
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Api\Field\Mutation;
6
7
use Application\Enum\Site;
8
use Application\Model\Statistic;
9
use Application\Repository\StatisticRepository;
10
use Ecodev\Felix\Api\Field\FieldInterface;
11
use GraphQL\Type\Definition\Type;
12
13
class RecordSearch implements FieldInterface
14
{
15 1
    public static function build(): iterable
16
    {
17 1
        yield 'recordSearch' => fn () => [
18 1
            'type' => Type::nonNull(Type::boolean()),
19 1
            'description' => 'Record one search in statistics',
20 1
            'resolve' => function ($root, array $args): bool {
0 ignored issues
show
Unused Code introduced by
The parameter $args is not used and could be removed. ( Ignorable by Annotation )

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

20
            'resolve' => function ($root, /** @scrutinizer ignore-unused */ array $args): bool {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
21
                /** @var Site $site */
22
                $site = $root['site'];
23
24
                /** @var StatisticRepository $statisticRepository */
25
                $statisticRepository = _em()->getRepository(Statistic::class);
26
                $statistic = $statisticRepository->getOrCreate($site);
27
                $statistic->recordSearch();
28
29
                _em()->flush();
30
31
                return true;
32 1
            },
33 1
        ];
34
    }
35
}
36