MattermostClientFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 23
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A createMattermostConfigDto() 0 7 1
A createMattermostApi() 0 5 1
A createClient() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of forecast.it.fill project.
7
 * (c) Patrick Jaja <[email protected]>
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace ForecastAutomation\MattermostClient;
13
14
use ForecastAutomation\Kernel\AbstractFactory;
15
use ForecastAutomation\MattermostClient\Business\MattermostApi;
16
use ForecastAutomation\MattermostClient\Shared\Dto\MattermostConfigDto;
17
use GuzzleHttp\Client;
18
19
class MattermostClientFactory extends AbstractFactory
20
{
21
    public function createMattermostConfigDto(): MattermostConfigDto
22
    {
23
        return new MattermostConfigDto(
24
            $_ENV['MATTERMOST_HOST'],
25
            $_ENV['MATTERMOST_USER_ID'],
26
            $_ENV['MATTERMOST_PASSWORD'],
27
            $_ENV['MATTERMOST_TEAM_ID'],
28
        );
29
    }
30
31
    public function createMattermostApi(): MattermostApi
32
    {
33
        return new MattermostApi(
34
            $this->createClient(),
35
            $this->createMattermostConfigDto(),
36
        );
37
    }
38
39
    public function createClient(): Client
40
    {
41
        return new Client(['base_uri' => (string) $_ENV['MATTERMOST_HOST']]);
42
    }
43
}
44