CreatePostController::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 15
rs 9.9666
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace App\Http\Controllers\Posts;
6
7
use App\Http\Controllers\Controller;
8
use Illuminate\Http\Request;
9
use Illuminate\Http\Response;
10
use TrophyForum\Posts\Application\Create\CreatePostCommand;
11
use TrophyForum\Posts\Application\Create\CreatePostCommandHandler;
12
13
final class CreatePostController extends Controller
14
{
15
    public function __invoke(Request $request): Response
16
    {
17
        $this->bus->addHandler(CreatePostCommand::class, CreatePostCommandHandler::class);
18
19
        $this->bus->dispatch(
20
            new CreatePostCommand(
21
                $request->get('id'),
0 ignored issues
show
Bug introduced by
It seems like $request->get('id') can also be of type null; however, parameter $id of TrophyForum\Posts\Applic...tCommand::__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

21
                /** @scrutinizer ignore-type */ $request->get('id'),
Loading history...
22
                $request->get('sub_forum_id'),
0 ignored issues
show
Bug introduced by
It seems like $request->get('sub_forum_id') can also be of type null; however, parameter $subForumId of TrophyForum\Posts\Applic...tCommand::__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

22
                /** @scrutinizer ignore-type */ $request->get('sub_forum_id'),
Loading history...
23
                $request->get('author_id'),
0 ignored issues
show
Bug introduced by
It seems like $request->get('author_id') can also be of type null; however, parameter $authorId of TrophyForum\Posts\Applic...tCommand::__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

23
                /** @scrutinizer ignore-type */ $request->get('author_id'),
Loading history...
24
                $request->get('title'),
0 ignored issues
show
Bug introduced by
It seems like $request->get('title') can also be of type null; however, parameter $title of TrophyForum\Posts\Applic...tCommand::__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('title'),
Loading history...
25
                $request->get('content')
0 ignored issues
show
Bug introduced by
It seems like $request->get('content') can also be of type null; however, parameter $content of TrophyForum\Posts\Applic...tCommand::__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('content')
Loading history...
26
            )
27
        );
28
29
        return Response::create(null, Response::HTTP_CREATED);
30
    }
31
}
32