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