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

ForecastClientFactory::createClient()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
ccs 0
cts 2
cp 0
crap 2
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