Passed
Push — master ( 653498...1099cb )
by Patrick
03:08
created

ForecastClientFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 30.76%

Importance

Changes 0
Metric Value
eloc 11
c 0
b 0
f 0
dl 0
loc 24
rs 10
ccs 4
cts 13
cp 0.3076
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A createForecastConfigDto() 0 8 1
A createForecastApi() 0 5 1
A createClient() 0 3 1
1
<?php
2
3
namespace ForecastAutomation\ForecastClient;
4
5
use ForecastAutomation\ForecastClient\Business\ForecastApi;
6
use ForecastAutomation\ForecastClient\Shared\Dto\ForecastConfigDto;
7
use ForecastAutomation\Kernel\AbstractFactory;
8
use GuzzleHttp\Client;
9
10
class ForecastClientFactory extends AbstractFactory
11
{
12
    public function createForecastConfigDto(): ForecastConfigDto
13
    {
14
        return new ForecastConfigDto(
15
            $_ENV['FORECAST_HOST'],
16
            $_ENV['FORECAST_API_KEY'],
17
            $_ENV['FORECAST_PROJECT_ID'],
18
            $_ENV['FORECAST_PERSON_ID'],
19
            $_ENV['FORECAST_FALLBACK_TASK_ID'],
20
        );
21
    }
22
23 1
    public function createForecastApi(): ForecastApi
24
    {
25 1
        return new ForecastApi(
26 1
            $this->createClient(),
27 1
            $this->createForecastConfigDto(),
28
        );
29
    }
30
31
    public function createClient(): Client
32
    {
33
        return new Client(['base_uri' => (string)$_ENV['FORECAST_HOST']]);
34
    }
35
}
36