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

Api   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 18
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A ping() 0 9 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