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

RecordPage::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1.125

Importance

Changes 0
Metric Value
eloc 11
c 0
b 0
f 0
dl 0
loc 17
ccs 6
cts 12
cp 0.5
rs 9.9
cc 1
nc 1
nop 0
crap 1.125
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