Passed
Push — master ( 5da018...ff48bc )
by Sam
07:31
created

TerminateBooking   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 14
c 0
b 0
f 0
dl 0
loc 23
ccs 11
cts 11
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A build() 0 21 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Api\Field\Mutation;
6
7
use Application\Api\Helper;
8
use Application\Model\Booking;
9
use Ecodev\Felix\Api\Field\FieldInterface;
10
use GraphQL\Type\Definition\Type;
11
use Mezzio\Session\SessionInterface;
12
13
abstract class TerminateBooking implements FieldInterface
14
{
15 4
    public static function build(): array
16
    {
17
        return [
18 1
            'name' => 'terminateBooking',
19 1
            'type' => Type::nonNull(_types()->getOutput(Booking::class)),
20 1
            'description' => 'Terminate a booking',
21
            'args' => [
22 1
                'id' => Type::nonNull(_types()->getId(Booking::class)),
23 1
                'comment' => Type::string(),
24
            ],
25
            'resolve' => function ($root, array $args, SessionInterface $session): Booking {
1 ignored issue
show
Unused Code introduced by
The parameter $session is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

25
            'resolve' => function ($root, array $args, /** @scrutinizer ignore-unused */ SessionInterface $session): Booking {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
26
                /** @var Booking $booking */
27 4
                $booking = $args['id']->getEntity();
28
29
                // Check ACL
30 4
                Helper::throwIfDenied($booking, 'update');
31
32 3
                $booking->terminate($args['comment'] ?? null);
33 3
                _em()->flush();
34
35 3
                return $booking;
36 1
            },
37
        ];
38
    }
39
}
40