Conditions | 2 |
Paths | 1 |
Total Lines | 22 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 2.0094 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | 1 | public static function build(): array |
|
16 | { |
||
17 | 1 | return [ |
|
18 | 1 | 'name' => 'validateExport', |
|
19 | 1 | 'type' => Type::string(), |
|
20 | 1 | 'description' => 'Validates that a new export can indeed be created. If valid return `null`, else return a message to be shown to end-user.', |
|
21 | 1 | 'args' => [ |
|
22 | 1 | 'input' => Type::nonNull(_types()->get(CreateExportInputType::class)), |
|
|
|||
23 | 1 | ], |
|
24 | 1 | 'resolve' => function (array $root, array $args): ?string { |
|
25 | 1 | _em()->beginTransaction(); |
|
26 | |||
27 | try { |
||
28 | 1 | CreateExport::create($args); |
|
29 | } catch (ClientAware $e) { |
||
30 | return $e->getMessage(); |
||
31 | } finally { |
||
32 | // Never keep things in DB |
||
33 | 1 | _em()->rollback(); |
|
34 | } |
||
35 | |||
36 | 1 | return null; |
|
37 | 1 | }, |
|
41 |