Completed
Pull Request — master (#180)
by Łukasz
05:27 queued 02:14
created

AddProductReviewByCodeRequest::getCommand()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Sylius\ShopApiPlugin\Request;
6
7
use Sylius\ShopApiPlugin\Command\AddProductReviewByCode;
8
use Symfony\Component\HttpFoundation\Request;
9
10 View Code Duplication
final class AddProductReviewByCodeRequest
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
11
{
12
    /** @var string */
13
    private $slug;
14
15
    /** @var string */
16
    private $channelCode;
17
18
    /** @var string */
19
    private $title;
20
21
    /** @var int */
22
    private $rating;
23
24
    /** @var string */
25
    private $comment;
26
27
    /** @var string */
28
    private $email;
29
30
    public function __construct(Request $request)
31
    {
32
        $this->slug = $request->attributes->get('code');
33
34
        $this->title = $request->request->get('title');
35
        $this->channelCode = $request->request->get('channelCode');
36
        $this->rating = $request->request->get('rating');
37
        $this->comment = $request->request->get('comment');
38
        $this->email = $request->request->get('email');
39
    }
40
41
    public function getCommand(): AddProductReviewByCode
42
    {
43
        return new AddProductReviewByCode($this->slug, $this->channelCode, $this->title, $this->rating, $this->comment, $this->email);
44
    }
45
}
46