RegisterController::__invoke()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 11
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 17
rs 9.9
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace App\Http\Controllers\Users;
6
7
use App\Http\Controllers\Controller;
8
use Exception;
9
use Illuminate\Http\JsonResponse;
10
use Illuminate\Http\Request;
11
use TrophyForum\Users\Application\Register\RegisterUserCommand;
12
use TrophyForum\Users\Application\Register\RegisterUserCommandHandler;
13
14
final class RegisterController extends Controller
15
{
16
    public function __invoke(Request $request): JsonResponse
17
    {
18
        $this->bus->addHandler(RegisterUserCommand::class, RegisterUserCommandHandler::class);
19
20
        try {
21
            return JsonResponse::create(
22
                $this->bus->dispatch(
23
                    new RegisterUserCommand(
24
                        $request->get('name'),
0 ignored issues
show
Bug introduced by
It seems like $request->get('name') can also be of type null; however, parameter $name of TrophyForum\Users\Applic...rCommand::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

24
                        /** @scrutinizer ignore-type */ $request->get('name'),
Loading history...
25
                        $request->get('email'),
0 ignored issues
show
Bug introduced by
It seems like $request->get('email') can also be of type null; however, parameter $email of TrophyForum\Users\Applic...rCommand::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

25
                        /** @scrutinizer ignore-type */ $request->get('email'),
Loading history...
26
                        $request->get('password'),
0 ignored issues
show
Bug introduced by
It seems like $request->get('password') can also be of type null; however, parameter $password of TrophyForum\Users\Applic...rCommand::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

26
                        /** @scrutinizer ignore-type */ $request->get('password'),
Loading history...
27
                        $request->get('country')
0 ignored issues
show
Bug introduced by
It seems like $request->get('country') can also be of type null; however, parameter $country of TrophyForum\Users\Applic...rCommand::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

27
                        /** @scrutinizer ignore-type */ $request->get('country')
Loading history...
28
                    )
29
                )
30
            );
31
        } catch (Exception $exception) {
32
            return JsonResponse::create(['error' => $exception->getMessage()], 400);
33
        }
34
    }
35
}
36