Passed
Branch master (fbf0a6)
by Volodymyr
04:04
created

CurlPost   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A submit() 0 5 1
A __construct() 0 4 1
1
<?php
2
/**
3
 * Copyright (c) 2019. Volodymyr Hryvinskyi.  All rights reserved.
4
 * @author: <mailto:[email protected]>
5
 * @github: <https://github.com/hryvinskyi>
6
 */
7
8
declare(strict_types=1);
9
10
namespace Hryvinskyi\InvisibleCaptcha\Model\ReCaptcha\RequestMethod;
11
12
use Hryvinskyi\InvisibleCaptcha\Model\ReCaptcha\RequestMethodInterface;
13
use Hryvinskyi\InvisibleCaptcha\Model\ReCaptcha\RequestParameters;
14
use Magento\Framework\HTTP\Client\Curl;
15
16
/**
17
 * Class CurlPost
18
 */
19
class CurlPost implements RequestMethodInterface
20
{
21
    /**
22
     * @var Curl
23
     */
24
    private $curl;
25
26
    /**
27
     * CurlPost constructor.
28
     *
29
     * @param Curl $curl
30
     */
31
    public function __construct(
32
        Curl $curl
33
    ) {
34
        $this->curl = $curl;
35
    }
36
37
    /**
38
     * @inheritDoc
39
     */
40
    public function submit(string $url, RequestParameters $params): string
41
    {
42
        $this->curl->post($url, $params->toQueryString());
43
44
        return $this->curl->getBody();
45
    }
46
}
47