Completed
Pull Request — master (#10)
by Sullivan
03:02
created

ClientFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 23
ccs 5
cts 5
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createClient() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Algatux\InfluxDbBundle\Services;
6
7
use InfluxDB\Client;
8
9
/**
10
 * Factory to build InfluxDB\Client instances.
11
 */
12
final class ClientFactory
13
{
14
    /**
15
     * @param string $host
16
     * @param string $httpPort
17
     * @param string $udpPort
18
     * @param string $user
19
     * @param string $password
20
     * @param bool   $udp
21
     *
22
     * @return Client
23
     */
24 1
    public static function createClient(string $host, string $httpPort, string $udpPort, string $user, string $password, bool $udp = false)
25
    {
26 1
        $client = new Client($host, $httpPort, $user, $password);
27
28 1
        if ($udp) {
29 1
            $client->setDriver(new \InfluxDB\Driver\UDP($client->getHost(), $udpPort));
30
        }
31
32 1
        return $client;
33
    }
34
}
35