Code Duplication    Length = 36-48 lines in 2 locations

src/Request/AddProductReviewByCodeRequest.php 1 location

@@ 10-45 (lines=36) @@
7
use Sylius\ShopApiPlugin\Command\AddProductReviewByCode;
8
use Symfony\Component\HttpFoundation\Request;
9
10
final class AddProductReviewByCodeRequest
11
{
12
    /** @var string */
13
    private $code;
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->code = $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->code, $this->channelCode, $this->title, $this->rating, $this->comment, $this->email);
44
    }
45
}
46

src/Request/AddProductReviewBySlugRequest.php 1 location

@@ 10-57 (lines=48) @@
7
use Sylius\ShopApiPlugin\Command\AddProductReviewBySlug;
8
use Symfony\Component\HttpFoundation\Request;
9
10
final class AddProductReviewBySlugRequest
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
    public function getCommand(): AddProductReviewBySlug
54
    {
55
        return new AddProductReviewBySlug($this->slug, $this->channelCode, $this->title, $this->rating, $this->comment, $this->email);
56
    }
57
}
58