Passed
Push — master ( 302558...609380 )
by Jared
51s
created

Api::ping()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 2
eloc 6
nc 2
nop 2
1
<?php
2
namespace CultureKings\Afterpay\Factory;
3
4
use CultureKings\Afterpay\Service\Ping;
5
use Doctrine\Common\Annotations\AnnotationRegistry;
6
use GuzzleHttp\Client;
7
use GuzzleHttp\ClientInterface;
8
9
/**
10
 * Class Api
11
 * @package CultureKings\Afterpay\Factory
12
 */
13
abstract class Api
14
{
15
    /**
16
     * @param                      $endpoint
17
     * @param ClientInterface|null $client
18
     *
19
     * @return Ping
20
     */
21
    public static function ping(
22
        $endpoint,
23
        ClientInterface $client = null
24
    ) {
25
        AnnotationRegistry::registerLoader('class_exists');
26
27
        $afterpayClient = $client ?: new Client([ 'base_uri' => $endpoint ]);
28
        return new Ping($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...
29
    }
30
}
31