Failed Conditions
Push — master ( 27554e...857869 )
by Luca
09:08
created

RecordPage   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 1
eloc 12
c 0
b 0
f 0
dl 0
loc 19
ccs 6
cts 12
cp 0.5
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\Model\Statistic;
8
use Application\Repository\StatisticRepository;
9
use Ecodev\Felix\Api\Field\FieldInterface;
10
use GraphQL\Type\Definition\Type;
11
12
class RecordPage implements FieldInterface
13
{
14 1
    public static function build(): array
15
    {
16 1
        return [
17 1
            'name' => 'recordPage',
18 1
            'type' => Type::nonNull(Type::boolean()),
19 1
            'description' => 'Record one page visit in statistics',
20 1
            'resolve' => function (array $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 (array $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
                $site = $root['site'];
22
23
                /** @var StatisticRepository $statisticRepository */
24
                $statisticRepository = _em()->getRepository(Statistic::class);
25
                $statistic = $statisticRepository->getOrCreate($site);
26
                $statistic->recordPage();
27
28
                _em()->flush();
29
30
                return true;
31 1
            },
32 1
        ];
33
    }
34
}
35