Failed Conditions
Push — master ( 257b90...0418d2 )
by Sam
08:13
created

UpdateOrderStatus::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 36
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1.156

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 15
nc 1
nop 0
dl 0
loc 36
ccs 6
cts 13
cp 0.4615
crap 1.156
rs 9.7666
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Api\Field\Mutation;
6
7
use Application\Api\Enum\OrderStatusType;
8
use Application\Api\Field\FieldInterface;
9
use Application\Model\Order;
10
use GraphQL\Type\Definition\Type;
11
use Mezzio\Session\SessionInterface;
12
13
abstract class UpdateOrderStatus implements FieldInterface
14
{
15 1
    public static function build(): array
16
    {
17
        return [
18 1
            'name' => 'updateOrderStatus',
19 1
            'type' => _types()->getOutput(Order::class),
20 1
            'description' => 'Make an order to the shop.',
21
            'args' => [
22 1
                'id' => Type::nonNull(_types()->getId(Order::class)),
23 1
                'status' => Type::nonNull(_types()->get(OrderStatusType::class)),
1 ignored issue
show
Bug introduced by
_types()->get(Applicatio...OrderStatusType::class) of type GraphQL\Type\Definition\Type is incompatible with the type GraphQL\Type\Definition\NullableType expected by parameter $wrappedType of GraphQL\Type\Definition\Type::nonNull(). ( Ignorable by Annotation )

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

23
                'status' => Type::nonNull(/** @scrutinizer ignore-type */ _types()->get(OrderStatusType::class)),
Loading history...
24
            ],
25
            'resolve' => function ($root, array $args, SessionInterface $session): ?Order {
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): ?Order {

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
                global $container;
27
28
                $status = $args['status'];
29
30
                $order = $args['id']->getEntity();
31
                $order->setStatus($status);
32
33
                // Todo : send notification to customer
34
                //
35
                //                if ($status === Order::STATUS_VALIDATED) {
36
                //                    /** @var Mailer $mailer */
37
                //                    $mailer = $container->get(Mailer::class);
38
                //
39
                //                    /** @var MessageQueuer $messageQueuer */
40
                //                    $messageQueuer = $container->get(MessageQueuer::class);
41
                //
42
                //                    // Notify user
43
                //                    $message = $messageQueuer->queueValidatedOrder($user, $user->getEmail());
44
                //                    $mailer->sendMessageAsync($message);
45
                //                }
46
47
                _em()->flush();
48
                _em()->refresh($order);
49
50
                return $order;
51 1
            },
52
        ];
53
    }
54
}
55