Conditions | 2 |
Paths | 1 |
Total Lines | 20 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 2.1821 |
Changes | 0 |
1 | <?php |
||
16 | 1 | public static function build(): iterable |
|
17 | { |
||
18 | 1 | yield 'extraStatistics' => fn () => [ |
|
19 | 1 | 'type' => Type::nonNull(Type::string()), |
|
20 | 1 | 'description' => 'JSON encoded extra statistics', |
|
21 | 1 | 'args' => [ |
|
22 | 1 | 'period' => Type::nonNull(Type::string()), |
|
23 | 1 | 'user' => _types()->getId(User::class), |
|
24 | 1 | ], |
|
25 | 1 | 'resolve' => function ($root, array $args): string { |
|
26 | /** @var Site $site */ |
||
27 | $site = $root['site']; |
||
28 | |||
29 | /** @var StatisticRepository $repository */ |
||
30 | $repository = _em()->getRepository(Statistic::class); |
||
31 | $user = @$args['user'] ? $args['user']->getEntity() : null; |
||
32 | |||
33 | $result = $repository->getExtraStatistics($site, $args['period'], $user); |
||
34 | |||
35 | return json_encode($result); |
||
36 | 1 | }, |
|
40 |