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

HttpClientTestTrait::createHttpClient()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 1
nc 1
nop 2
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