WithFakeHttpClient   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 6
c 0
b 0
f 0
dl 0
loc 11
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A mockHttpClient() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chemaclass\StockTickerTests\Unit;
6
7
use Symfony\Contracts\HttpClient\HttpClientInterface;
8
use Symfony\Contracts\HttpClient\ResponseInterface;
9
10
trait WithFakeHttpClient
11
{
12
    private function mockHttpClient(string $responseBody = ''): HttpClientInterface
13
    {
14
        $response = $this->createMock(ResponseInterface::class);
0 ignored issues
show
Bug introduced by
It seems like createMock() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

14
        /** @scrutinizer ignore-call */ 
15
        $response = $this->createMock(ResponseInterface::class);
Loading history...
15
        $response->method('getContent')->willReturn($responseBody);
16
17
        $httpClient = $this->createMock(HttpClientInterface::class);
18
        $httpClient->method('request')->willReturn($response);
19
20
        return $httpClient;
21
    }
22
}
23