Code Duplication    Length = 48-48 lines in 2 locations

src/Api/PaymentIntent.php 1 location

@@ 18-65 (lines=48) @@
15
use Shapin\Stripe\Model\PaymentIntent\PaymentIntentCollection;
16
use Symfony\Component\Config\Definition\Processor;
17
18
final class PaymentIntent extends HttpApi
19
{
20
    /**
21
     * @throws Exception
22
     */
23
    public function get(string $id)
24
    {
25
        $response = $this->httpGet("payment_intents/$id");
26
27
        return $this->hydrator->hydrate($response, PaymentIntentModel::class);
28
    }
29
30
    /**
31
     * @throws Exception
32
     */
33
    public function all(array $params = [])
34
    {
35
        $response = $this->httpGet('payment_intents', $params);
36
37
        return $this->hydrator->hydrate($response, PaymentIntentCollection::class);
38
    }
39
40
    /**
41
     * @throws Exception
42
     */
43
    public function create(array $params)
44
    {
45
        $processor = new Processor();
46
        $processor->processConfiguration(new Configuration\PaymentIntentCreate(), [$params]);
47
48
        $response = $this->httpPost('payment_intents', $params);
49
50
        return $this->hydrator->hydrate($response, PaymentIntentModel::class);
51
    }
52
53
    /**
54
     * @throws Exception
55
     */
56
    public function confirm(string $id, array $params = [])
57
    {
58
        $processor = new Processor();
59
        $processor->processConfiguration(new Configuration\PaymentIntentConfirm(), [$params]);
60
61
        $response = $this->httpPost("payment_intents/$id/confirm", $params);
62
63
        return $this->hydrator->hydrate($response, PaymentIntentModel::class);
64
    }
65
}
66

src/Api/Product.php 1 location

@@ 18-65 (lines=48) @@
15
use Shapin\Stripe\Model\Product\ProductCollection;
16
use Symfony\Component\Config\Definition\Processor;
17
18
final class Product extends HttpApi
19
{
20
    /**
21
     * @throws Exception
22
     */
23
    public function get(string $productId)
24
    {
25
        $response = $this->httpGet("products/$productId");
26
27
        return $this->hydrator->hydrate($response, ProductModel::class);
28
    }
29
30
    /**
31
     * @throws Exception
32
     */
33
    public function create(array $params)
34
    {
35
        $processor = new Processor();
36
        $params = $processor->processConfiguration(new Configuration\ProductCreate(), [$params]);
37
38
        $response = $this->httpPost('products', $params);
39
40
        return $this->hydrator->hydrate($response, ProductModel::class);
41
    }
42
43
    /**
44
     * @throws Exception
45
     */
46
    public function update(string $id, array $params)
47
    {
48
        $processor = new Processor();
49
        $params = $processor->processConfiguration(new Configuration\ProductUpdate(), [$params]);
50
51
        $response = $this->httpPost("products/$id", $params);
52
53
        return $this->hydrator->hydrate($response, ProductModel::class);
54
    }
55
56
    /**
57
     * @throws Exception
58
     */
59
    public function all(array $params = [])
60
    {
61
        $response = $this->httpGet('products', $params);
62
63
        return $this->hydrator->hydrate($response, ProductCollection::class);
64
    }
65
}
66