| Conditions | 2 |
| Paths | 1 |
| Total Lines | 26 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 17 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | 1 | public static function build(): iterable |
|
| 19 | { |
||
| 20 | 1 | yield 'suggestCreation' => fn () => [ |
|
| 21 | 1 | 'type' => Type::nonNull(_types()->getOutput(Change::class)), |
|
| 22 | 1 | 'description' => 'Suggest the creation of a new image', |
|
| 23 | 1 | 'args' => [ |
|
| 24 | 1 | 'id' => Type::nonNull(_types()->getId(Card::class)), |
|
| 25 | 1 | 'request' => Type::nonNull(Type::string()), |
|
| 26 | 1 | ], |
|
| 27 | 1 | 'resolve' => function ($root, array $args): Change { |
|
| 28 | /** @var Site $site */ |
||
| 29 | 1 | $site = $root['site']; |
|
| 30 | |||
| 31 | 1 | $suggestion = $args['id']->getEntity(); |
|
| 32 | |||
| 33 | /** @var ChangeRepository $changeRepository */ |
||
| 34 | 1 | $changeRepository = _em()->getRepository(Change::class); |
|
| 35 | 1 | $change = $changeRepository->getOrCreate(ChangeType::Create, $suggestion, $args['request'], $site); |
|
| 36 | |||
| 37 | 1 | Helper::throwIfDenied($change, 'create'); |
|
| 38 | |||
| 39 | 1 | if (!$change->getId()) { |
|
|
|
|||
| 40 | 1 | _em()->flush(); |
|
| 41 | } |
||
| 42 | |||
| 43 | 1 | return $change; |
|
| 44 | 1 | }, |
|
| 48 |
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
integervalues, zero is a special case, in particular the following results might be unexpected: