| Conditions | 3 |
| Paths | 1 |
| Total Lines | 26 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 4.679 |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | 1 | public static function build(): array |
|
| 17 | { |
||
| 18 | return [ |
||
| 19 | 1 | 'name' => 'terminateBooking', |
|
| 20 | 1 | 'type' => Type::nonNull(_types()->getOutput(Booking::class)), |
|
| 21 | 1 | 'description' => 'Terminate a booking', |
|
| 22 | 'args' => [ |
||
| 23 | 1 | 'id' => Type::nonNull(_types()->getId(Booking::class)), |
|
| 24 | 1 | 'comment' => Type::string(), |
|
| 25 | ], |
||
| 26 | 'resolve' => function ($root, array $args, SessionInterface $session): Booking { |
||
|
1 ignored issue
–
show
|
|||
| 27 | $booking = $args['id']->getEntity(); |
||
| 28 | |||
| 29 | // Check ACL |
||
| 30 | Helper::throwIfDenied($booking, 'update'); |
||
| 31 | |||
| 32 | // Booking can only be terminated once |
||
| 33 | if (!$booking->getEndDate()) { |
||
| 34 | $booking->setEndDate(Utility::getNow()); |
||
| 35 | if (@$args['comment']) { |
||
| 36 | $booking->setEndComment($args['comment']); |
||
| 37 | } |
||
| 38 | _em()->flush(); |
||
| 39 | } |
||
| 40 | |||
| 41 | return $booking; |
||
|
1 ignored issue
–
show
|
|||
| 42 | 1 | }, |
|
| 46 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.