Passed
Push — master ( d8adb5...0c7712 )
by Ger
09:30 queued 21s
created

RatePostController   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 14
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 12 1
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\Rate\CreateRateCommand;
11
use TrophyForum\Posts\Application\Rate\CreateRateCommandHandler;
12
13
final class RatePostController extends Controller
14
{
15
    public function __invoke(string $postId, Request $request): Response
16
    {
17
        $this->bus->addHandler(CreateRateCommand::class, CreateRateCommandHandler::class);
18
19
        $this->bus->dispatch(
20
            new CreateRateCommand(
21
                $postId,
22
                $request->get('like')
0 ignored issues
show
Bug introduced by
It seems like $request->get('like') can also be of type null; however, parameter $like of TrophyForum\Posts\Applic...eCommand::__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('like')
Loading history...
23
            )
24
        );
25
26
        return Response::create(null, Response::HTTP_OK);
27
    }
28
}
29