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

ClientFactory::createClient()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

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