RecordSearch   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 45.45%

Importance

Changes 0
Metric Value
wmc 1
eloc 11
c 0
b 0
f 0
dl 0
loc 19
ccs 5
cts 11
cp 0.4545
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A build() 0 17 1
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