Completed
Pull Request — master (#146)
by Łukasz
10:35 queued 06:48
created

AddReviewRequest::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Sylius\ShopApiPlugin\Request;
6
7
use Sylius\ShopApiPlugin\Command\AddReview;
8
use Symfony\Component\HttpFoundation\Request;
9
10
final class AddReviewRequest
11
{
12
    /**
13
     * @var string
14
     */
15
    private $slug;
16
17
    /**
18
     * @var string
19
     */
20
    private $channelCode;
21
22
    /**
23
     * @var string
24
     */
25
    private $title;
26
27
    /**
28
     * @var int
29
     */
30
    private $rating;
31
32
    /**
33
     * @var string
34
     */
35
    private $comment;
36
37
    /**
38
     * @var string
39
     */
40
    private $email;
41
42
    public function __construct(Request $request)
43
    {
44
        $this->slug = $request->attributes->get('slug');
45
46
        $this->title = $request->request->get('title');
47
        $this->channelCode = $request->request->get('channelCode');
48
        $this->rating = $request->request->get('rating');
49
        $this->comment = $request->request->get('comment');
50
        $this->email = $request->request->get('email');
51
    }
52
53
    /**
54
     * @return AddReview
55
     */
56
    public function getCommand(): AddReview
57
    {
58
        return new AddReview($this->slug, $this->channelCode, $this->title, $this->rating, $this->comment, $this->email);
59
    }
60
}
61