Completed
Pull Request — master (#339)
by Alejandro
07:42
created

ApiTestCase   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 16
c 0
b 0
f 0
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A callApi() 0 3 1
A setApiClient() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace ShlinkioTest\Shlink\Common\ApiTest;
5
6
use Fig\Http\Message\RequestMethodInterface;
7
use Fig\Http\Message\StatusCodeInterface;
8
use GuzzleHttp\ClientInterface;
9
use PHPUnit\Framework\TestCase;
10
use Psr\Http\Message\ResponseInterface;
11
12
abstract class ApiTestCase extends TestCase implements StatusCodeInterface, RequestMethodInterface
13
{
14
    /** @var ClientInterface */
15
    private static $client;
16
17
    public static function setApiClient(ClientInterface $client): void
18
    {
19
        self::$client = $client;
20
    }
21
22
    /**
23
     * @throws \GuzzleHttp\Exception\GuzzleException
24
     */
25
    protected function callApi(string $method, string $uri, array $options = []): ResponseInterface
26
    {
27
        return self::$client->request($method, $uri, $options);
28
    }
29
}
30