Api::ping()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 2
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
class Api
14
{
15
    /**
16
     * @param string               $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
29
        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...
30
    }
31
}
32