Passed
Push — master ( 8a1132...707256 )
by Jared
58s
created

MerchantApi::ping()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 10
rs 9.4285
c 1
b 0
f 1
cc 2
eloc 6
nc 2
nop 2
1
<?php
2
namespace CultureKings\Afterpay\Factory;
3
4
use CultureKings\Afterpay\Model\Merchant\Authorization;
5
use CultureKings\Afterpay\Service\Merchant\Configuration as ConfigurationService;
6
use CultureKings\Afterpay\Service\Merchant\Payments as PaymentsService;
7
use CultureKings\Afterpay\Service\Merchant\Orders as OrdersService;
8
use CultureKings\Afterpay\Service\Merchant\Ping as PingService;
9
use Doctrine\Common\Annotations\AnnotationRegistry;
10
use GuzzleHttp\Client;
11
use GuzzleHttp\ClientInterface;
12
use JMS\Serializer\SerializerInterface;
13
14
/**
15
 * Class MerchantApi
16
 * @package CultureKings\Afterpay\Factory
17
 */
18
class MerchantApi extends Api
19
{
20
    /**
21
     * @param Authorization            $authorization
22
     * @param Client|null              $client
23
     * @param SerializerInterface|null $serializer
24
     * @return ConfigurationService
25
     */
26
    public static function configuration(
27
        Authorization $authorization,
28
        Client $client = null,
29
        SerializerInterface $serializer = null
30
    ) {
31
    
32
        AnnotationRegistry::registerLoader('class_exists');
33
34
        $afterpayClient = $client ? : new Client([ 'base_uri' => $authorization->getEndpoint() ]);
35
        $afterpaySerializer = $serializer ? : SerializerFactory::getSerializer();
36
37
        return new ConfigurationService($afterpayClient, $authorization, $afterpaySerializer);
38
    }
39
40
    /**
41
     * @param Authorization            $authorization
42
     * @param Client|null              $client
43
     * @param SerializerInterface|null $serializer
44
     * @return PaymentsService
45
     */
46
    public static function payments(
47
        Authorization $authorization,
48
        Client $client = null,
49
        SerializerInterface $serializer = null
50
    ) {
51
    
52
        AnnotationRegistry::registerLoader('class_exists');
53
54
        $afterpayClient = $client ? : new Client([ 'base_uri' => $authorization->getEndpoint() ]);
55
        $afterpaySerializer = $serializer ? : SerializerFactory::getSerializer();
56
57
        return new PaymentsService($afterpayClient, $authorization, $afterpaySerializer);
58
    }
59
60
    /**
61
     * @param Authorization            $authorization
62
     * @param Client|null              $client
63
     * @param SerializerInterface|null $serializer
64
     * @return OrdersService
65
     */
66
    public static function orders(
67
        Authorization $authorization,
68
        Client $client = null,
69
        SerializerInterface $serializer = null
70
    ) {
71
        AnnotationRegistry::registerLoader('class_exists');
72
73
        $afterpayClient = $client ? : new Client([ 'base_uri' => $authorization->getEndpoint() ]);
74
        $afterpaySerializer = $serializer ? : SerializerFactory::getSerializer();
75
76
        return new OrdersService($afterpayClient, $authorization, $afterpaySerializer);
77
    }
78
79
    /**
80
     * @param string               $endpoint
81
     * @param ClientInterface|null $client
82
     *
83
     * @return Ping
84
     */
85
    public static function ping(
86
        $endpoint,
87
        ClientInterface $client = null
88
    ) {
89
        AnnotationRegistry::registerLoader('class_exists');
90
91
        $afterpayClient = $client ?: new Client([ 'base_uri' => $endpoint ]);
92
93
        return new PingService($afterpayClient);
0 ignored issues
show
Compatibility introduced by
$afterpayClient of type object<GuzzleHttp\ClientInterface> is not a sub-type of object<GuzzleHttp\Client>. It seems like you assume a concrete implementation of the interface GuzzleHttp\ClientInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
94
    }
95
}
96