Completed
Push — master ( 3e9c3d...99411a )
by Hugo
22s queued 11s
created

HttpClientTestTrait   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A createHttpClient() 0 12 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yproximite\WannaSpeakBundle\Tests;
6
7
use Symfony\Component\HttpClient\MockHttpClient;
8
use Symfony\Contracts\HttpClient\ResponseInterface;
9
use Yproximite\WannaSpeakBundle\HttpClient;
10
11
trait HttpClientTestTrait
12
{
13
    /**
14
     * @param callable|callable[]|ResponseInterface|ResponseInterface[]|iterable|null $responseFactory
15
     */
16
    public function createHttpClient($responseFactory = null, bool $test = false): HttpClient
17
    {
18
        $baseUri = 'https://www-2.wannaspeak.com/api/api.php';
19
20
        return new HttpClient(
21
            '9999999999',
22
            '0000000000',
23
            $baseUri,
24
            $test,
25
            new MockHttpClient($responseFactory, $baseUri)
0 ignored issues
show
Bug introduced by
It seems like $responseFactory defined by parameter $responseFactory on line 16 can also be of type object<Symfony\Contracts...ient\ResponseInterface>; however, Symfony\Component\HttpCl...tpClient::__construct() does only seem to accept callable|null, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
26
        );
27
    }
28
}
29